none
Cannot get CSharpScript.EvaluateAsync to work because of System.Collections.Immutable RRS feed

  • Question

  • I built a simple C# COM Server using DotNet framework 4.7.1

    It has multiple methods and all work ok. However, I added a method to use Roslyn like so:

    int result1 = CSharpScript.EvaluateAsync<int>("2 + 2").Result;

    But when called from another C# program to test like so:

    Object result2 = com.GetType().InvokeMember("EvaluateTest", BindingFlags.Default | BindingFlags.InvokeMethod, null, ssicom, null);

    it fails with:

    System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

    Now I know about the wrong version being in the GAC (1.1.37).

    I have now tried multiple different Nuget package combinations of the packages to support Roslyn including the beta version. Nothing seems to get rid of the System.Collections.Immutable 1.2.1.0 reference. But 1.2.1 does not even exist in Nuget.

    Is it time to abandon Roslyn completely?

    Saturday, April 28, 2018 4:52 PM

All replies

  • BTW, ASMSpy shows:

    Reference: System.Collections.Immutable
      System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    Source: NotFound
        1.2.1.0 by Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        1.2.1.0 by Microsoft.CodeAnalysis.CSharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        1.2.1.0 by Microsoft.CodeAnalysis.CSharp.Scripting, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        1.2.1.0 by Microsoft.CodeAnalysis.Scripting, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
      System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    Source: Local, Location: C:\Dev\Project\bin\Debug\System.Collections.Immutable.dll
        1.2.3.0 by MyCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ffb4e07ca4e717d
        1.2.3.0 by System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    And I did try multiple versions of Microsoft.CodeAnalysis and its subclasses.

    The statement
    int result1 = CSharpScript.EvaluateAsync<int>("2 + 2").Result;

    works in a standalone Console application. But inside the COM server, something is different.

    Saturday, April 28, 2018 5:07 PM
  • Hi genify2,

    Thank you for posting here.

    Have you try to install the version 1.3.0 of System.Collections.Immutable? I installed it from NuGet. When you install it, you could check the version in the property of this assembly. It is 1.2.1.

    I hope this could fix you error.

    Best Regards,

    Wendy


    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, April 30, 2018 7:24 AM
    Moderator