2017-05-17 25 views
0

我試圖更新使用roslyn到4.7的解決方案。 當更新的NuGet包我收到以下錯誤:更新解決方案.net框架4.7:與Roslyn問題

One or more unresolved package dependency constraints detected in the existing packages.config file. All dependency constraints must be resolved to add or update packages. If these packages are being updated this message may be ignored, if not the following error(s) may be blocking the current package operation: 'System.Security.Cryptography.Algorithms 4.3.0 constraint: System.IO (>= 4.3.0)'

,然後嘗試使用羅斯林的時候,我得到一個異常運行下面的代碼:

var compilation = CSharpCompilation.Create("MyCompilation", new[] {syntaxTree}, references); 
var diag = compilation.GetDiagnostics(); 

唯一的例外是:

Managed Debugging Assistant 'BindingFailure' occurred HResult=0x00000000 Message=Managed Debugging Assistant 'BindingFailure' : 'The assembly with display name 'System.Security.Cryptography.Algorithms' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileLoadException: Could not load file or assembly 'System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

有關如何解決的任何想法?

回答

0

原來的問題是依賴程序集重定向。 它看起來像VS2017在我的app.config文件中添加了很多這些。

更改:

<dependentAssembly> 
    <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" /> 
    </dependentAssembly> 

與此:

<dependentAssembly> 
    <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.1.0.0" /> 
    </dependentAssembly> 

在我的主要項目app.config文件似乎已經做到了。

0

您可能想向我們展示packages.config文件的內容。 從你看起來需要將System.IO升級到4.3.0或更高版本,因爲System.Security.Cryptography.Algorithms需要它。