Web Api:找不到 System.Net.Http 版本 2.0.0.0 [英] Web Api: System.Net.Http version 2.0.0.0 not found
问题描述
当我为 WebApi 安装 NuGet 包时,它为我提供了 System.Net.Http 的 1.0.0.0 版本,但它引用了版本 2.
When I install the NuGet package for WebApi, it gives me version 1.0.0.0 of System.Net.Http, yet it references version 2.
我似乎一辈子都找不到版本 2.当我下载 .net 4.5 时,我得到 System.Net.Http 版本 4.0.315.x,但我无法使用它,因为 Web Api 程序集引用版本 2.0.0.0.
I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer to version 2.0.0.0.
有人知道我在哪里可以找到这个 2.0.0.0 版本吗?我已经尝试过 NuGet 包管理器、mvc4、.net 4.5,但没有给我版本 2.
Anyone know where I can find this version 2.0.0.0? I've tried the NuGet package manager, mvc4, .net 4.5, and nothing is giving me version 2.
提前致谢.
推荐答案
在
节点下的 Web.config 文件中添加以下配置(假设您的应用程序在 .NET 上运行4.5、targetFramework
属性设置为4.5):
Add the below configuration inside your Web.config file under <system.web>
node (assuming your app runs on .NET 4.5, targetFramework
attribute is set to 4.5):
<compilation targetFramework="4.5">
<assemblies>
<add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
还在
节点下的根级别添加以下内容:
Also add the below one at the root level under <configuration>
node:
<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>
这应该可以解决您的问题.
This should solve your problem.
这篇关于Web Api:找不到 System.Net.Http 版本 2.0.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!