无法加载文件或程序集"System.Net.Http,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a"

编程入门 行业动态 更新时间:2024-10-13 18:27:15
本文介绍了无法加载文件或程序集"System.Net.Http,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已将项目复制到仅安装了Visual Studio 2015社区和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,版本= 4.0.0.0,区域性=中性,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.Http在bin文件夹中找不到该文件.

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 Assemblies \ Microsoft \ Framework.NETFramework \ v4.6.1 \ System.Net.Http.dll

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Net.Http.dll

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

C:\ Development \ MyApp \ packages \ Microsoft.AspNet.WebApi.Client.5.2.3 \ lib \ net45 \ System.Net.Http.Formatting.dll

C:\Development\MyApp\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.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?

推荐答案

请遵循以下步骤,

  • 将Visual Studio更新到最新版本(重要)
  • 从web.config
  • 删除所有绑定重定向
  • 将此添加到 .csproj 文件:

  • Update visual studio to latest version (it matters)
  • Remove all binding redirects from web.config
  • 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,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d5

    本文发布于:2023-11-15 22:28:00,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1598509.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:区域性   加载   版本   文件   程序

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!