I have a textbox called ssd.
I want it to compile the C# code in it to "Prgoram.exe" at the same location.
I tried this:

                CSharpCodeProvider codeProvider = new CSharpCodeProvider();
                ICodeCompiler icc = codeProvider.CreateCompiler();
                System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
                parameters.GenerateExecutable = true;
                parameters.CompilerOptions = "/target:winexe";
                parameters.OutputAssembly = "Program.exe";
                parameters.GenerateInMemory = false; 
                CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, ssd.Text);

But it's not working. Can you solve it please?

Thanks in advance.

Recommended Answers

All 4 Replies

Did you check the results for error messages?

It have 2 errors because I'm using the windows.forms...
How to add a reference to the compiler?

Thanks a lot!
This solved my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.