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

Could not load file or assembly 'System.Web.Http, Version=5.2.2.0

我将 Odata v4 包 添加到我的 API,我注意到它更新了我的 Microsoft.AspNet.WebApi打包到 5.2.3 版本。但是当我尝试使用

odata builder configuation in my WebApiConfig it showing error like 'Could not load file or assembly 'System.Web.Http, Version=5.2.2.0'.

config.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));

我在我的项目中搜索了这个版本 (5.2.2),但所有东西都是 5.2.3,我也更新了所有包来解决这个问题但失败了。 复制到本地 属性 也适用于 System.Web.Http dll。
有什么想法吗?

Visual studio 帮我解决了这个问题。版本冲突显示为警告,当我单击它时,它会自动将绑定重定向添加到我的 Web 配置中。

https://msdn.microsoft.com/en-us/library/2fc472t2.aspx

解决我问题的绑定重定向是,

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31BF3856AD364E35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31BF3856AD364E35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
</assemblyBinding>

好吧,这不是 "real" 解决方案,而是一种变通方法: 我已经更改了 machine.config 并将 <runtime /> 替换为

  <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

所以我工作,但如果你有其他网站 运行...