无法加载文件或程序System.Net.Http,版本= 4.0.0.0与ASP.NET(MVC 4)的Web API的OData $ P $租赁前 [英] Could not load file or assembly System.Net.Http, Version=4.0.0.0 with ASP.NET (MVC 4) Web API OData Prerelease

查看:658
本文介绍了无法加载文件或程序System.Net.Http,版本= 4.0.0.0与ASP.NET(MVC 4)的Web API的OData $ P $租赁前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装在微软的ASP.NET Web API的OData包5.0.0-RC1 $ P $租赁前我结束了以下异常后:

After installing the Microsoft ASP.NET Web API OData package 5.0.0-rc1 prerelease I end up with the following exception:

无法加载文件或程序集System.Web.Http,版本= 4.0.0.0,
  文化=中性公钥= 31bf3856ad364e35'或一个其
  依赖。找到的程序集清单定义不
  匹配程​​序集引用。 (异常来自HRESULT:0x80131040)

Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我的MVC 4项目是全新的,非常小的,什么也没有看中。我针对的.NET framework 4.5

My MVC 4 project is brand new and really small, nothing fancy in it. I target .NET framework 4.5

我需要这个的NuGet包以<一个href=\"http://stackoverflow.com/questions/14177676/whats-the-currently-recommended-way-of-performing-partial-updates-with-web-api\">implement使用德尔塔类 PATCH
(当我使用的包4.0.0.0版本,三角洲类是不工作)。

I need this nuget package to implement PATCH using the Delta class (When I use the version 4.0.0.0 of the package, the Delta class is not working).

我该如何解决呢?

广汽我的版本的 5.0.0.0 System.Web.Http的

In GAC I have version 5.0.0.0 of System.Web.Http

GACUTIL -l System.Web.Http全局程序集缓存包含
  以下组件:System.Web.Http,版本5.0.0.0 =,
  文化=中性公钥= 31bf3856ad364e35,
  的ProcessorArchitecture = MSIL

gacutil -l System.Web.Http The Global Assembly Cache contains the following assemblies: System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL

的Visual Studio ,当我浏览组件,System.Web.Http的特定版本的 4.0.0.0 (为什么?)

In Visual Studio, when I browse assemblies, the given version of System.Web.Http is 4.0.0.0 (Why?)

我的项目,提到System.Web.Http

In my project, the reference to System.Web.Http


  • 的版本 5.0.0.0

  • 点到封装的\\ lib \\ net45 \\文件夹

  • 的CopyLocal = TRUE

我试图重定向v 4.0.0.0绑定到5.0.0.0在Web.config中

I tried to bind redirect v 4.0.0.0 to 5.0.0.0 in Web.config

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="4.0.0.0-4.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

但它给了我另一个异常:

But it gives me another exception:

尝试通过法System.Web.Http.GlobalConfiguration..cctor()来
  接入领域
  System.Web.Http.GlobalConfiguration.CS $&LT;> 9__CachedAnonymousMethodDelegate2
  失败了。

Attempt by method 'System.Web.Http.GlobalConfiguration..cctor()' to access field 'System.Web.Http.GlobalConfiguration.CS$<>9__CachedAnonymousMethodDelegate2' failed.

我想使V 4.0.0.0真的需要由核心网页API引擎使用。

I guess that v 4.0.0.0 really need to be used by core Web Api engine.

<一个href=\"http://stackoverflow.com/questions/12120741/$c$c-analysis-error-could-not-load-file-or-assembly-system-net-http-version-2\">$c$c分析错误无法加载文件或程序集System.Net.Http,版本= 2.0.0.0在MVC4的Web API
<一href=\"http://stackoverflow.com/questions/9431975/could-not-load-file-or-assembly-system-net-http-version-2-0-0-0-in-mvc4-web-ap\">Could无法加载文件或程序集System.Net.Http,版本= 2.0.0.0在MVC4的Web API

推荐答案

的Visual Studio 2013有一项新功能,以照顾这。当您生成的应用程序,你应该看到中引用有关不同版本的程序集的警告。双击警告集绑定重定向添加到Web.config。

Visual Studio 2013 has a new feature to take care of this. When you build the app, you should see warnings about different versions of an assembly being referenced. Double click the warning to add assembly binding redirects to the web.config.

请参阅http://msdn.microsoft.com/en-us/library/2fc472t2.aspx了解更多详情。

低于jeff.eynon笔记,你需要有web.config中签出(如果使用TFS源代码控制),以获得VS自动编辑的文件。谢谢你的提示!

jeff.eynon notes below that you need to have the web.config checked out (if using TFS source control) to get VS to edit the file automatically. Thanks for the tip!

这篇关于无法加载文件或程序System.Net.Http,版本= 4.0.0.0与ASP.NET(MVC 4)的Web API的OData $ P $租赁前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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