DLL 地狱 - 无法加载文件或程序集 System.Threading.Tasks.Extensions [英] DLL hell - Could not load file or assembly System.Threading.Tasks.Extensions
问题描述
我有一个非常简单的 .NET Framework 4.7.2 应用程序,其中包含以下 nuget:
I have very simple .NET Framework 4.7.2 app with the following nugets:
<packages>
<package id="Autofac" version="5.1.2" targetFramework="net472" />
<package id="DynamicData" version="6.14.8" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
<package id="MSBuildTasks" version="1.5.0.235" targetFramework="net472" developmentDependency="true" />
<package id="ReactiveUI" version="11.2.3" targetFramework="net472" />
<package id="Serilog" version="2.9.0" targetFramework="net472" />
<package id="Serilog.Enrichers.Process" version="2.0.1" targetFramework="net472" />
<package id="Serilog.Enrichers.Thread" version="3.1.0" targetFramework="net472" />
<package id="Serilog.Sinks.File" version="4.1.0" targetFramework="net472" />
<package id="Splat" version="9.3.11" targetFramework="net472" />
<package id="System.Reactive" version="4.3.2" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
如您所见,4.5.3
版本中引用了System.Threading.Tasks.Extensions
(我无法更改此版本,因为其他包依赖在上面).
As you can see, there is System.Threading.Tasks.Extensions
referenced in version 4.5.3
(I can't change this version, because other packages depend on it).
当我在 Visual Studio 解决方案资源管理器中转到此 DLL 引用的属性时,它显示从 .....\packages\System.Threading.Tasks 引用的版本
.4.2.0.1
.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
When I go to properties of this DLL reference in Visual Studio Solution Explorer, it shows version 4.2.0.1
referenced from .....\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
.
在app.config
中有自动生成的绑定重定向:
In app.config
there is automatically generated binding redirect:
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
当我运行应用程序时,出现异常:
When I run the app, I get exception:
我已经尝试将绑定重定向更改为:
I already tried to change binding redirect to something like:
<bindingRedirect oldVersion="0.0.0.0-99.99.99.99" newVersion="4.5.3" />
但问题依然存在.我不知道如何解决这个 dll 问题.任何帮助将不胜感激.
But the issue persists. I have no idea how to resolve this dll-hell. Any help will be much appreciated.
推荐答案
当我在 Visual Studio 中访问此 DLL 引用的属性时解决方案资源管理器,显示从 xxxxxx 引用的版本 4.2.0.1
When I go to properties of this DLL reference in Visual Studio Solution Explorer, it shows version 4.2.0.1 referenced from xxxxxx
首先,我觉得你对DLL版本
和nuget版本
有点误解.
First, I think you have a little misunderstanding about the DLL version
and the nuget version
.
version 4.5.3
只是 nuget 包 System.Threading.Tasks.Extensions
的版本编号,而 version 4.2.0.1
只是 System.Threading.Tasks.Extensions.dll
(存在于 nuget pacakge 中)编号.它们根本不是一个概念.你可以在xxx.csproj
文件中看到这样的dll引用.
version 4.5.3
is just the nuget package System.Threading.Tasks.Extensions
's version
number while version 4.2.0.1
is just the System.Threading.Tasks.Extensions.dll
( exist in the nuget pacakge) number. They are not a concept at all. And you can see such dlls referenced in xxx.csproj
file.
一个版本的nuget包包含多个针对不同项目框架的相互竞争的DLLS,会根据nuget机制自动安装到对应的项目中.
A version of the nuget package contains multiple competing DLLS for different project frameworks, which will be automatically installed into the corresponding project according to the nuget mechanism.
DLL 地狱 - 无法加载文件或程序集System.Threading.Tasks.Extensions
DLL hell - Could not load file or assembly System.Threading.Tasks.Extensions
正如您所说,您有一个名为 System.Reactive version 4.3.2
的 nuget 包,它依赖于 System.Threading.Tasks.Extensions 4.5.3
在您的项目中.你可以看到这个:
As you said, you have a nuget package called System.Reactive version 4.3.2
that depends on System.Threading.Tasks.Extensions 4.5.3
in your project. You can see this:
从您的错误日志来看,该项目似乎引用了 System.Threading.Tasks.Extensions.dll 4.2.0.0
,但它在 nuget 包 System.Threading 中不存在.Tasks.Extensions 4.5.3
应该是System.Threading.Tasks.Extensions.dll 4.2.0.1
.不确定您是否更改了版本号或项目的原因.
And from your error log, it seems that the project referenced System.Threading.Tasks.Extensions.dll 4.2.0.0
which it does not exists in the nuget package System.Threading.Tasks.Extensions 4.5.3
and it should be System.Threading.Tasks.Extensions.dll 4.2.0.1
. Not sure if you changed the version number or the reason for the project.
您可以检查以下步骤:
解决方案
1) 确保 packages.config
中的 System.Threading.Tasks.Extensions
版本为 4.5.3
代码>文件.
1) make sure that System.Threading.Tasks.Extensions
version is 4.5.3
in packages.config
file.
2) 确保将 xxx.csproj
文件中的 dll 版本更改为 4.2.0.1
2) make sure that you change the dll version to 4.2.0.1
in xxx.csproj
file
3) 在重新安装这些之前,请先清理nuget缓存,然后在Tools
下运行update-Package -reinstall
code>-->Nuget Package Manager
->Package Manager Console
重新安装包
3) Before you reinstall these, please clean the nuget cache first, then run update-Package -reinstall
under Tools
-->Nuget Package Manager
->Package Manager Console
to reinstall the packages
4)新建一个framework 4.7.2项目,然后引用这些nuget包来测试是否是你的项目造成的.
4) create a new framework 4.7.2 project and then referenced these nuget packages to test whether it is caused by your project.
这篇关于DLL 地狱 - 无法加载文件或程序集 System.Threading.Tasks.Extensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!