none
compile error when compiling C# code with the CSharpCodeProvider class RRS feed

  • Question

  • The situation is that i have an application which is using assembly redirection (https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) to be able to use assemblies that have a different version at run-time then what version was used for building the assemblies. This is working, except for when i try to compile some additional code in C#, using the CSharpCodeProvider class. This is returning an error 'Assembly A version=X1 uses B, version=Y2 which has a higher version than referenced assembly B, version=Y1'.

    Is there something additional i need to do to make the CSharpCodeProvider aware of the assembly redirection ?

    This is how i compile the code :

    public static CompilerResults CheckSyntax (string code)
    {
        List<string> dllList = <list of DLL names>;
        CompilerParameters parameters = new CompilerParameters(dllList.ToArray(), <output DLL name>);
        ...
        CSharpCodeProvider codeProvider = new CSharpCodeProvider();
        return codeProvider.CompileAssemblyFromSource(parameters, code);
    }
    


    Sunday, March 5, 2017 9:01 PM

All replies

  • Hi Kris,

    How about the result if you don't use  assembly redirection?

    Or could you also show a simplified demo here or a screen capture?

    Best regards,

    Kristin  


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 6, 2017 7:25 AM
  • Without assembly redirection the application will not start.

    (This is .NET framework version 4.0 by the way.)

    Monday, March 6, 2017 7:35 AM