Roslyn Microsoft.CodeAnalysis.CSharp.Scripting
I've been trying to play around with Roslyn scripting using LinqPad but have had no luck. I find that with LinqPad 5.08.01 the full Microsoft.CodeAnalysis.CSharp.Scripting NuGet package doesn't seem be loaded (the Microsoft.CodeAnalysis.CSharp.Scripting.dll assembly is missing).
With the Beta 5.09.01 I'm able to reference everything but evaluating expressions with CSharpScript throws exceptions.
For example, the following program throws
The same sample running in a Console application works fine. Any ideas what's missing? Thanks.
With the Beta 5.09.01 I'm able to reference everything but evaluating expressions with CSharpScript throws exceptions.
For example, the following program throws
MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray`1 System.Reflection.Metadata.MetadataReader.GetBlobContent(System.Reflection.Metadata.BlobHandle)'I've pulled in Microsoft.CodeAnalysis.CSharp.Scripting 1.3.2 and have included the Microsoft.CodeAnalysis.CSharp.Scripting namespace. The NuGet package also pulls in System.Collections.Immutable and System.Reflection.Metadata referred to in the exception.
The same sample running in a Console application works fine. Any ideas what's missing? Thanks.
void Main() { int result = 0; var globals = new Globals { X = 80, Y = 10 }; CSharpScript.EvaluateAsync<int>("X+Y", null, globals).ContinueWith(s => result = s.Result).Wait(); } public class Globals { public int X; public int Y; }
Comments
The first is to use the prerelease version of Microsoft.CodeAnalysis.CSharp.Scripting, which doesn't reference a version of CodeAnalysis that's likely to be in the GAC.
The second is to manually specify binding redirects, which you can copy from the app.config file that VS creates when you add the NuGet package.
Go to Query | App.Config, and paste the following in: I'll let you know when there's an automatic fix for this.
https://www.linqpad.net/Download.aspx#beta
LINQPad now identifies the problem scenario and creates binding redirects on the fly.