Question

I'm trying to compile a .cs file using a CSharpCodeProvider from a .net 3.5 app and I want to target the .net4 compiler but I'm getting this error "Compiler executable file csc.exe cannot be found". I have .net4 installed. Below is the code that I'm using with some lines omitted for brevity. When I set CompilerVersion to "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));
}
Was it helpful?

Solution

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

But not vice versa.

(I can be wrong).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top