Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify .NET version for .NET 4 C# compiler from microsoft?

I want to compile a .NET 2.0 DLL by means CSharpCodeProvider from Microsoft .NET 4.0 Runtime. Is this possible?

By the way, Mono C# compiler can do it. using sdk parameter (2 and 4 supported).

like image 398
Ivan Efimov Avatar asked Jun 18 '11 00:06

Ivan Efimov


1 Answers

Something like this should work:

 Dictionary<string, string> options = new Dictionary<string, string>();
 options.Add("CompilerVersion", "v2.0");
 CSharpCodeProvider provider = new CSharpCodeProvider(options);

See: CSharpCodeProvider Constructor (IDictionary).

like image 153
hammar Avatar answered Oct 05 '22 23:10

hammar