无法加载文件或程序集System.Web.Http,Version = 5.2.2.0

Mik*_*e_G 22 asp.net web-config assemblybinding asp.net-web-api assembly-binding-redirect

我刚刚将Asp.Net Web Api 2.2项目上传到生产服务器,我收到了标题中的错误.

在我的Web.config中我已经有了这个:

 <dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
  </dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

该文件确实存在于bin中.什么会导致这个?
我的所有Asp.Net Web API文件都是最新的,并显示5.2.2作为版本.它在我的开发机器上工作正常.

Mih*_*scu 36

设置Copy Localtrue在对性能System.Web.HttpSystem.Web.Http.WebHost组件并重新部署软件包.

如果这不能解决您的问题,请尝试重新安装NuGet包.这有望纠正破坏的依赖关系.从包管理控制台,运行以下命令:

Update-Package Microsoft.AspNet.WebApi -reinstall
Run Code Online (Sandbox Code Playgroud)

一定要安装System.Web.Http.WebHost.

  • 重新安装它对我来说是这样的。 (3认同)

Dan*_*l B 9

对我来说,从"解决方案资源管理器"我检查了项目引用中的"System.Web.Http"的版本,这是5.2.3.0所以,在web.config中,我更改了:

<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> 
Run Code Online (Sandbox Code Playgroud)

<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.3.0" />
Run Code Online (Sandbox Code Playgroud)

然后建立.它对我有用!