簡體   English   中英

更新.net Framework 4.7的解決方案:Roslyn的問題

[英]Updating solution to .net framework 4.7: issue with Roslyn

我正在嘗試將使用roslyn的解決方案更新為4.7。 更新nuget軟件包時,出現以下錯誤:

在現有packages.config文件中檢測到一個或多個未解決的程序包依賴關系約束。 必須解決所有依賴性約束,才能添加或更新程序包。 如果正在更新這些軟件包,則可能會忽略此消息,如果不是,則以下錯誤可能阻止當前的軟件包操作:'System.Security.Cryptography.Algorithms 4.3.0約束:System.IO(> = 4.3.0 )”

然后,當嘗試使用Roslyn時,我得到一個運行以下代碼的異常:

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

例外是:

發生托管調試助手'BindingFailure'HResult = 0x00000000消息= 托管調試助手'BindingFailure': '顯示名稱為'System.Security.Cryptography.Algorithms'的程序集無法加載ID為1的AppDomain的'LoadFrom'綁定上下文中。失敗的原因是:System.IO.FileLoadException:無法加載文件或程序集'System.Security.Cryptography.Algorithms,版本= 4.0.0.0,區域性=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依賴項之一。 找到的程序集的清單定義與程序集引用不匹配。 (來自HRESULT的異常:0x80131040)

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

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

原來問題是依賴程序集重定向。 看起來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文件中似乎已經完成了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM