.net framework 4.7 的更新解决方案:Roslyn 问题
Updating solution to .net framework 4.7: issue with Roslyn
我正在尝试将使用 roslyn 的解决方案更新到 4.7。
更新 nuget 包时出现以下错误:
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)'
然后,当尝试使用 Roslyn 时,我得到一个异常 运行 以下代码:
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)'
知道如何解决吗?
您可能想向我们展示 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文件中似乎已经做到了。
我正在尝试将使用 roslyn 的解决方案更新到 4.7。 更新 nuget 包时出现以下错误:
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)'
然后,当尝试使用 Roslyn 时,我得到一个异常 运行 以下代码:
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)'
知道如何解决吗?
您可能想向我们展示 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文件中似乎已经做到了。