我的PC上安装了VS 11 Beta,.net 4.5和MVC 4 beta.我刚刚下载了最新的RC,现在我尝试运行Web项目时收到此错误消息.我尝试重新安装.net 4.5和卸载和树脂安装VS 12 RC,但没有工作.我试过了
建议 here也没有工作.
建议 here也没有工作.
堆
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,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\testNew\testNew\App_Start\RouteConfig.cs Line: 28 Stack Trace: [TypeLoadException: Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http,PublicKeyToken=31bf3856ad364e35'.] testNew.RouteConfig.RegisterRoutes(RouteCollection routes) in c:\projects\testNew\testNew\App_Start\RouteConfig.cs:28 testNew.MvcApplication.Application_Start() in c:\projects\testNew\testNew\Global.asax.cs:25 [HttpException (0x80004005): Could not load type 'System.Web.Http.RouteParameter' from assembly 'System.Web.Http,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,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
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35
而不是我的项目.重命名此文件使我的项目工作,但我显然不能在我的共享托管网站上这样做.
我已经手动引用了dll
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies
并将其设置为复制到本地.仍然从gac_msil加载.如何覆盖这个?
解决方法
我有同样的问题,并发现这个问题,而谷歌在错误.
当我看到我的窗口上安装的程序,我看到有3个MVC 4’应用程序安装:
当我看到我的窗口上安装的程序,我看到有3个MVC 4’应用程序安装:
> MVC 4 VS 2010工具
> MVC 4
> MVC 4(Bundle)
我卸载了“MVC 4”应用程序,然后我的项目工作正常.