CSharpCodeProvider: finding valid CompilerVersion RRS feed

  • Question

  • I've developed a C# program under Visual Studio 2008 / .Net 3.5.  Part of the program allows users to edit C# code files and compile them using the CSharpCodeProvider.

    It's always worked fine until recently when a new user got the following exception.

    Method not found: “void Microsoft.CSharp.CsharpCode.Provider..ctor”

    I thought the problem might be that they don't have .Net 3.5 installed and I'm requesting CompilerVersion "v3.5" in my software.  They do have several varieties of .Net 1.1, 2.0, 3.0, and 4.0.  I thought I'd be able to just request a CompilerVersion of "v4.0" or "v3.0" but neither works when testing on my local development machine and I get the error "Compiler executable file csc.exe cannot be found." (I do have .Net 4.0 installed.)

    So, I guess I have two questions.

    1.  How is my .Net 3.5 program running at all as .Net 3.5 isn't installed?  I'm guessing it's running under .Net 4.0.

    2. Can I request the CSharpCodeProvider compile under version 3.0 or 4.0 when my program is built on 3.5?  I believe that if I don't specify a compiler version it's using 2.0 as some of my Linq code fails.

    Much appreciated.


    Monday, April 16, 2012 5:39 PM


  • Try this on the system in question:

    Control Panel->Programs and Features...

    Click Turn Windows features on and off.

    In the features list, find the node Microsoft .NET Framework 3.5.1 (this is ,net Framework 2.0/3.0/3.5 with all patches through 3.5 SP1).

    Expand the node and activate all subfeatures.

    If that does not help, you may want to ask the C# experts in the C# developer forums:

    • Edited by pvdg42 Tuesday, April 17, 2012 1:49 PM
    • Proposed as answer by Alexander Sun Wednesday, April 18, 2012 5:18 AM
    • Marked as answer by Alexander Sun Tuesday, May 8, 2012 3:31 AM
    Tuesday, April 17, 2012 1:47 PM

All replies