【问题标题】:Method 'CommonCreateArrayTypeSymbol' does not have an implementation方法“CommonCreateArrayTypeSymbol”没有实现
【发布时间】:2019-10-30 22:59:58
【问题描述】:

我有非常简单的代码,它使用 nuget Microsoft.CodeAnalysis.CSharp.Scripting:

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

一个月前它工作得很好,现在突然间我开始在这里收到异常:

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.'

【问题讨论】:

    标签: c# csharpscript


    【解决方案1】:

    我发现我的 nuget 依赖项版本不匹配:

    <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" />
    

    一旦我将“Microsoft.CodeAnalysis.Common”从“3.3.1”更新到“3.1.0” - 一切恢复正常。

    【讨论】:

      【解决方案2】:

      在一轮 NuGet 包更新之后,我在使用 Razor“编辑并继续”或他们所说的任何东西时遇到了类似的问题。通过remming解决:

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

      在我的主应用程序/网络项目文件中。

      我遇到的错误,具体来说是:

        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()
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-07
        • 2020-07-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多