How to allow my .net program to compile C # code while running?

I saw a couple of .net applications that let you select the C # .cs source file, and the program itself will compile this code and run it.

How it's done?

+4
source share
4 answers

It probably uses the CSharpCodeProvider class in the Microsoft.CSharp namespace. You want to see the following methods for compiling code:

CompileAssemblyFromDom CompileAssemblyFromFile CompileAssemblyFromSource 
+11
source

CodeDOM is your friend

+2
source

MSDN has an excellent series of articles explaining this ...

http://msdn.microsoft.com/en-us/library/650ax5cx.aspx

+1
source

My assumption is to explicitly call the csc.exe compiler. Keep in mind that this and any dependencies should be included in your deployment.

You can look at CS-Script , which interprets C # files. Its free, but not open sources, though ...

0
source

All Articles