2016-09-29 85 views
0

項目羅斯林編譯器升級的依賴關係之後開始拋出缺少方法異常下面的代碼之前更新工作:羅斯林dependenceis MissingMethodException

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

EmitResult compileResult; 
generatedAssembly = string.Empty; 

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

現在,它拋出MissingMethod例外:

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

所有依賴關係更新爲當前最新版本:

<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

嘗試清潔您的解決方案。如果您在運行時加載錯誤的DLL版本,就會發生這種情況。 – SLaks

回答

2

這件事是通過this bug羅斯林引起的,因此增加組裝重定向幫助:

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

,但應用程序仍然使用1.2.0.0版本不可變的集合

+0

.csproj中庫的項目引用也必須更改。 .. \ packages \ System.Collections.Immutable.1.1.37 \ lib \ portable-net45 + win8 + wp8 + wpa81 \ System.Collections.Immutable.dll True madufit1