Method 'CommonCreateArrayTypeSymbol' does not have an implementation

1.6k views Asked by At

I have very simple code, which uses nuget Microsoft.CodeAnalysis.CSharp.Scripting:

var script = CSharpScript.Create($@"
IntProp1 = 123;
IntProp2 = 456;
return IntProp1 + IntProp2;
");
var errors = script.Compile();

It was working perfectly fine month ago, now all of a sudden I started receiving exception here:

System.TypeLoadException: 'Method 'CommonCreateArrayTypeSymbol' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilation' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.'
2

There are 2 answers

0
Philipp Munin On

I figure out that I had mismatched versions of nuget dependencies:

<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="3.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="3.1.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.6.0" />

Once I updated "Microsoft.CodeAnalysis.Common" from "3.3.1" to "3.1.0" - everything went back to normal.

0
Luke Puplett On

I had a similar problem with Razor "edit and continue" or whatever they call it, after a round of NuGet package updates. Solved by remming out:

<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.11.0" />

Which was in my main app/web project file.

The error I had, specifically was:

  An unhandled exception has occurred while executing the request.
  System.TypeLoadException: Method 'get_CommonSyntaxTrees' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilation' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=3.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
     at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()