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.
Stack
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\testNew\testNew\App_Start\RouteConfig.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\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, 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
Edit 6
I used fuslogvw
and found out that the project was referencing the System.Web.Http.dll
from here
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Http\v4.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.
I've manually referenced the dll from
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies
and set it to Copy to Local
. Still it loads from gac_msil
. How do I override this?
I had the same problem, and found this question while googling on the error. When I looked at the installed programs on my windows, I saw there were 3 MVC 4 'applications' installed:
I uninstalled the "MVC 4" application and then my projects worked fine.
For now the answer is to replace the dll from the folder
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies
into
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With