![](/img/trans.png)
[英]Could not load file or assembly 'System.Net.Http, Version=4.1.0.0 .net framework 4.6 .net standard 1.3
[英]Could not load file or assembly 'System.Net.Http, Version=4.1.1.1 .Net Standard
我正在构建一个.Net标准库,它构建良好,但在测试时,我得到了这个错误
HResult = -2147024894消息=无法加载文件或程序集'System.Net.Http,Version = 4.1.1.1,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。 该系统找不到指定的文件。 来源=图书馆试验
我已经安装了System.Net.Http Nuget Package仍然没有成功。 这是一个新项目,所以我必须做错什么
正如Ved Tiwari上面所说,删除app.config(或解决方案/项目)中对“4.1.1.1”的引用。
例如,我删除了以下内容并重新开始工作:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
如果您安装了System.Diagnostics.DiagnosticSource
依赖项,请将其删除并将System.Net.Http
更新为4.1.1.1版
为了在我的解决方案中修复同样的错误,我不仅从Web.config中删除了System.Net.Http
的bindingRedirect
( 请参阅@ Rado的回答 ),还需要从它的引用中删除Version
, Culture
等和HintPath
。项目文件( * .csproj )。
基本上,改变了* .csproj
<Reference Include="System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
至
<Reference Include="System.Net.Http"/>
在web.config
文件中添加以下内容:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.0.0.0" />
</dependentAssembly>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.