本文介绍了Visual Studio 2012 RC 无法加载类型 System.Web.Http.RouteParameter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 PC 上安装了 VS 11 Beta、.net 4.5 和 MVC 4 beta.我刚刚下载了最新的 RC,现在当我尝试运行 Web 项目时收到此错误消息.我尝试重新安装 .net 4.5 并卸载并重新安装 VS 12 RC,但这没有用.我试过建议 这里 也没有用.

I had VS 11 Beta, .net 4.5 and MVC 4 beta installed on my PC. I just downloaded the latest RC and now I get this error message when I try to run web projects. I tried reinstalling .net 4.5 and uninstalling and resinstalling VS 12 RC but that hasn't worked. I tried the suggestion here which didn't work either.

堆栈

Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error:


Line 26:                 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
Line 27:             );
Line 28:         }
Line 29:     }
Line 30: }


Source File: c:projects	estNew	estNewApp_StartRouteConfig.cs    Line: 28

Stack Trace:


[TypeLoadException: Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
   testNew.RouteConfig.RegisterRoutes(RouteCollection routes) in c:projects	estNew	estNewApp_StartRouteConfig.cs:28
   testNew.MvcApplication.Application_Start() in c:projects	estNew	estNewGlobal.asax.cs:25

[HttpException (0x80004005): Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9841101
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9850940
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17626 

编辑 6

我使用了 fuslogvw 并发现该项目从这里引用了 System.Web.Http.dll

I used fuslogvw and found out that the project was referencing the System.Web.Http.dll from here

C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Httpv4.0_4.0.0.0__31bf3856ad364e35

而不是我的项目.重命名此文件使我的项目正常工作,但我显然无法在我的共享托管站点上执行此操作.

instead of my project. Renaming this file made my project work but I obviously can't do this on my shared hosting site.

我已经手动引用了

C:Program Files (x86)Microsoft ASP.NETASP.NET MVC 4Assemblies

并将其设置为Copy to Local.它仍然从 gac_msil 加载.我如何覆盖它?

and set it to Copy to Local. Still it loads from gac_msil. How do I override this?

推荐答案

现在的答案是从文件夹中替换 dll

For now the answer is to replace the dll from the folder

C:Program Files (x86)Microsoft ASP.NETASP.NET MVC 4Assemblies

进入

C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Httpv4.0_4.0.0.0__31bf3856ad364e35

在 Beta 之上升级到 RC 在另一台机器上工作.我希望这对未来的人有所帮助.

upgrading over top of the Beta to the RC worked on another machine. I hope this helps someone in the future.

如果我找到更好的答案,我会更新

I'll update if I find a better answer

这篇关于Visual Studio 2012 RC 无法加载类型 System.Web.Http.RouteParameter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:12