Is it possible to configure the .net4 compiler from a .net3.5 application using CSharpCodeProvider?

I am trying to compile a .cs file using CSharpCodeProvider from a .net 3.5 application, and I want to target the .net4 compiler, but I get this error "Csc.exe compiler executable could not be found." I have .net4 installed. Below is the code I'm using, with some lines omitted for brevity. When I install CompilerVersion in "v3.5", I get no errors.

CompilerResults results = null; using (CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<string, string>() {{"CompilerVersion", "v4.0"},})) { CompilerParameters options = new CompilerParameters(); ... results = provider.CompileAssemblyFromFile(options, Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories)); } 
+6
source share
1 answer

I think you can force to use csc v3.5 from .NET 4.0.

But not the other way around.

(I could be wrong).

+4
source

Source: https://habr.com/ru/post/904466/


All Articles