无法加载文件或程序集“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [英] Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

查看:29
本文介绍了无法加载文件或程序集“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的项目复制到仅安装了 Visual Studio 2015 Community 和 SQL Server 2016 Express 的干净的 Windows 10 计算机.除了随 Windows 10 和 VS2015 或 SQL Server 安装的框架版本之外,没有安装其他框架版本.

I've copied my project to a clean Windows 10 machine with only Visual Studio 2015 Community and SQL Server 2016 Express installed. There are no other framework versions installed apart from those installed with Windows 10 and VS2015 or SQL Server.

当我尝试启动 WebApi 项目时,我收到以下消息:

When I try to start the WebApi project I get the message:

无法加载文件或程序集System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"或其依赖项之一.系统找不到指定的文件.

Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of its dependencies. The system cannot find the file specified.

项目的包包括:

<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />

使用 .NET Framework 4.6.1 构建项目后,System.Net.Httpbin 文件夹中找不到该文件.

After building the project with .NET Framework 4.6.1, System.Net.Http the file is not found in the bin folder.

文件路径指向:

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.6.1System.Net.Http.dll

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.6.1System.Net.Http.dll

System.Net.Http.Formatting的文件路径指向:

C:DevelopmentMyApppackagesMicrosoft.AspNet.WebApi.Client.5.2.3lib et45System.Net.Http.Formatting.dll

C:DevelopmentMyApppackagesMicrosoft.AspNet.WebApi.Client.5.2.3lib et45System.Net.Http.Formatting.dll

整个项目应该针对 4.5.1 还是有其他方法可以引用正确的程序集?

Should the whole project target 4.5.1 or is there another way to reference the right assemblies?

推荐答案

请按照以下步骤操作,

  1. 将 Visual Studio 更新到最新版本(这很重要)
  2. web.config
  3. 中删除所有绑定重定向
  4. 将此添加到 .csproj 文件:

  1. Update visual studio to latest version (it matters)
  2. Remove all binding redirects from web.config
  3. Add this to the .csproj file:

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

  • 构建项目
  • bin 文件夹中应该有一个(WebAppName).dll.config 文件
  • 它应该有重定向,将它们复制到 web.config
  • .csproj 文件中删除上面的片段
  • Build the project
  • In the bin folder there should be a (WebAppName).dll.config file
  • It should have redirects in it, copy these to the web.config
  • Remove the above snipped from the .csproj file
  • 应该可以

    这篇关于无法加载文件或程序集“System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆