0

We're experiencing a weird problem at runtime when running code that uses the CSharpScripting classes.

Here a sample code to reproduce the error:

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        try
        {
            // Creating the script
            var compiled = CSharpScript.Create<string>(@"return ""ciao"";");
            compiled.Compile();
            var runner = compiled.CreateDelegate();

            var result = runner().GetAwaiter().GetResult();

            Assert.AreEqual("ciao", result);
        }
        catch (Exception ex)
        {

        }
    }
}

The test does not run, it compiles but throw at runtime

System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray1<Microsoft.CodeAnalysis.Diagnostic> Microsoft.CodeAnalysis.Scripting.Script.Compile(System.Threading.CancellationToken)'.`

Any help is appreciated!

0

1 Answer 1

1

Try Update assembly Like this

 <dependentAssembly>
    <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.1.37.0" newVersion="1.1.37.0" />
  </dependentAssembly>

Refrenced This answer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.