Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 842421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:57:28+00:00 2026-05-15T05:57:28+00:00

Can someone help me with this issue? I currently working on my project for

  • 0

Can someone help me with this issue?

I currently working on my project for final year of my honors degree. And we are developing a application to evaluate programming assignments of student ( for 1st year student level)

I just want to know how to integrate C++ compiler using C# code to compile C++ code.

In our case we are loading a student C++ code into text area, then with a click on button we want to compile the code. And if there any compilation errors it will be displayed on text area nearby. (Interface is attached herewith.)

And finally it able to execute the code if there aren’t any compilation errors. And results will be displayed in console.

We were able to do this with a C#(C# code will be loaded to text area intead of C++ code) code using inbuilt compiler. But still not able to do for C# code.

Can anyone suggest a method to do this? It is possible to integrate external compiler to VS C# code? If possible how to achieve it?

Very grateful if anyone will contributing to solve this matter?

This is code for Build button which we proceed with C# code compiling

CodeDomProvider codeProvider = CodeDomProvider.CreateProvider(“csharp”);
string Output = “Out.exe”;
Button ButtonObject = (Button)sender;

        rtbresult.Text = "";
        System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
        //Make sure we generate an EXE, not a DLL
        parameters.GenerateExecutable = true;
        parameters.OutputAssembly = Output;
        CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, rtbcode.Text);

        if (results.Errors.Count > 0)
        {

            rtbresult.ForeColor = Color.Red;
            foreach (CompilerError CompErr in results.Errors)
            {
                rtbresult.Text = rtbresult.Text +
                            "Line number " + CompErr.Line +
                            ", Error Number: " + CompErr.ErrorNumber +
                            ", '" + CompErr.ErrorText + ";" +
                            Environment.NewLine + Environment.NewLine;
            }
        }
        else
        {
            //Successful Compile
            rtbresult.ForeColor = Color.Blue;
            rtbresult.Text = "Success!";
            //If we clicked run then launch our EXE
            if (ButtonObject.Text == "Run") Process.Start(Output); // Run button
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:57:29+00:00Added an answer on May 15, 2026 at 5:57 am

    there is unfortunately no default implementation for CodeDom for C++, you can always define your own if you want to use the same code as the above to compile C++.

    Or you can call cl.exe directly, In both cases you would have to manually invoke cl.exe

    http://msdn.microsoft.com/en-us/library/19z1t1wy(v=VS.71).aspx

    It shouldn’t that hard. write the code to a temporary file, call cl.exe pipe any output to a window you want (or not) and the end, check if a exe has been produced, if it has compilation succeeded and you can run the exe, if not it failed and the error should be in the log you created earlier.

    It’s less structured than above but it’s by far the easiest way.

    — more detailed

    the following code assumes your environment vars are properly set. http://msdn.microsoft.com/en-us/library/f2ccy3wt(VS.80).aspx

    class CL
    {
        private const string clexe = @"cl.exe";
        private const string exe = "Test.exe", file = "test.cpp";
        private string args;
        public CL(String[] args)
        {
            this.args = String.Join(" ", args);
            this.args += (args.Length > 0 ? " " : "") + "/Fe" + exe + " " + file;
        }
    
        public Boolean Compile(String content, ref string errors)
        {
            //remove any old copies
            if (File.Exists(exe))
                File.Delete(exe);
            if(File.Exists(file))
                File.Delete(file);
    
            File.WriteAllText(file, content);
    
            Process proc = new Process();
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError = true;
            proc.StartInfo.FileName = clexe;
            proc.StartInfo.Arguments = this.args;
            proc.StartInfo.CreateNoWindow = true;
    
            proc.Start();
            //errors += proc.StandardError.ReadToEnd();
            errors += proc.StandardOutput.ReadToEnd();
    
            proc.WaitForExit();
    
            bool success = File.Exists(exe);
    
            return success;
        }
    }
    

    this will compile the code given to it, but it’s just a sample, everytime compilation succeeds there will be a file “Test.exe” which you can run. when it fails the “errors” variable will contain the error message.

    hope this helps,
    for more information on running processes, take a look at http://www.codeproject.com/KB/cs/ProcessStartDemo.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can help... This issue has been discussed here and I have
Can someone help me identify what the purpose of this unidentified syntax is. It
As a follow-up to this question I am hoping someone can help with the
Ok, this is bit of an obscure question, but hopefully someone can help me
Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone help explain the following: If I type: a=`ls -l` Then the output
Can someone help me with the getopt function? When I do the following in
Can someone just help me refresh my mind? How do you specify hex values
Can someone please help me out with printing the contents of an IFrame via
I am wondering if someone can help me figure out the best approach to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.