roslyn dependenceis MissingMethodException

ε祈祈猫儿з 提交于 2021-02-11 08:32:40

问题


After upgrading the dependencies in project roslyn compiler started to throw missing method exception in the following code that before update worked:

CSharpCompilation compilation = CreateCompilation(templateId, syntaxTrees, metadataReferences);

EmitResult compileResult;
generatedAssembly = string.Empty;

using (var stream = new MemoryStream())
{
    compileResult = compilation.Emit(stream);

Now its throwing MissingMethod exception:

System.MissingMethodException
Method not found: 'System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.Diagnostic> Microsoft.CodeAnalysis.Emit.EmitResult.get_Diagnostics()'.

All the dependencies are updated to current latest versions:

  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.CodeAnalysis.Common" version="1.3.2" targetFramework="net461" />
<package id="Microsoft.CodeAnalysis.CSharp" version="1.3.2" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.2.0" targetFramework="net461" />

fds


回答1:


The issue was caused by this bug in roslyn, so adding an assembly redirects helped:

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

but the app still uses 1.2.0.0 version of Immutable collections



来源:https://stackoverflow.com/questions/39771903/roslyn-dependenceis-missingmethodexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!