【发布时间】:2018-11-21 11:28:37
【问题描述】:
GAC 包含 system.net.http 2.0.0.0,但是构建过程抱怨找不到它:
The primary reference "ABC.dll" could not be resolved
because it has an indirect dependency on the framework assembly
"System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
which could not be resolved in the currently targeted framework.
".NETFramework,Version=v4.0".
ABC.dll 和我当前的项目都针对 .NET Framework 4
gacutil -l 的输出显示两个版本:
System.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
另外尝试过:
更改机器配置无济于事
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
做不到:
更改 .csproj、.net 版本或将正确的 .dll 与应用程序捆绑在一起。因为 abc.dll 和 system.net.http 依赖项作为 GAC 的一部分部署到客户端计算机,因此只允许对我的开发计算机进行更改。
【问题讨论】:
-
引用程序集永远不会来自 GAC,它在您运行程序之前不会执行它所做的事情。所以到目前为止你一直在看的东西并不能解决这个问题。您要从哪里获得参考程序集是模糊的,v2.0.0.0 已经很老了,而且 System.Net.Http 有大量的 DLL Hell 问题。您可以尝试使用旧版本的 nuget 包。有这么大的主版本差异当然是不健康的,重建 abc.dll 是明智的。
-
是的,最终从 Microsoft.net.http 包下的 nuget 获得它
标签: c# .net .net-assembly gac