Hi
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
}