2012-06-07 21 views
12

Tenía VS 11 Beta, .net 4.5 y MVC 4 beta instalados en mi PC. Acabo de descargar la última RC y ahora recibo este mensaje de error cuando intento ejecutar proyectos web. Intenté volver a instalar .NET 4.5 y desinstalar y volver a instalar VS 12 RC, pero eso no funcionó. Intenté la sugerencia here que tampoco funcionó.visual studio 2012 RC No se pudo cargar el tipo System.Web.Http.RouteParameter

Pila

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 

Editar 6

Solía ​​fuslogvw y descubrí que el proyecto se refería a la System.Web.Http.dll de aquí

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35 

en lugar de mi proyecto. Renombrar este archivo hizo que mi proyecto funcionara, pero obviamente no puedo hacer esto en mi sitio de alojamiento compartido.

que he referenciado manualmente el archivo DLL de

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

y la ponga a Copy to Local. Todavía carga de gac_msil. ¿Cómo anulo esto?

Respuesta

8

Por ahora la respuesta es reemplazar el archivo DLL de la carpeta

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

en

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35 

actualización sobre la parte superior de la Beta al RC trabajó en otro máquina. Espero que esto ayude a alguien en el futuro.

Voy a actualizar si puedo encontrar una mejor respuesta

+0

Esto no funcionó para mí. – FatAlbert

+1

Sí, funciona. @FatAlbert Asegúrese de reemplazar todos los ensamblajes incluidos los XML – om471987

+0

System.Web.Http no existe debajo de GAC_MSIL para mí. – Kyle

6

le sugiero que también actualiza desde MVC4 Beta a RC MVC4: http://www.asp.net/mvc/mvc4 Y de acuerdo con el comunicado señala: 'Puede actualizar el ASP.NET MVC 4 Developer Preview y Beta a ASP.NET MVC 4 Candidato de lanzamiento sin necesidad de desinstalar. '

Y lo hice y me deshice del error.

El motivo es que su aplicación está apuntando a la antigua MVC4 Beta en el GAC.

Una alternativa es usar la variable de entorno DEVPATH mencionada en este enlace. http://www.christophdebaene.com/blog/2012/04/06/building-the-source-code-of-asp-net-web-api/

Vicente

+0

Ya probé el DEVPATH como mencioné en mi OP. MVC 4 RC viene con 2012 RC. No hay opción para descargar esto por separado para 2012. También vea las ediciones más recientes – Eonasdan

+1

He actualizado mi pregunta nuevamente. ¿Alguna idea nueva? – Eonasdan

9

que tenía el mismo problema, y ​​encontré esta pregunta, mientras que buscando en Google sobre el error. Cuando miré a los programas instalados en las ventanas de mi, vi que había instalados 3 MVC 4 'aplicaciones':

  1. MVC 4 VS 2010 Herramientas
  2. MVC 4
  3. MVC 4 (Bundle)

Desinstalé la aplicación "MVC 4" y luego mis proyectos funcionaron bien.

+0

gracias por la adición de @roet. Ya había desinstalado todo lo que pude encontrar en el momento en que creé esta pregunta. No funcionó para mí, pero me alegra que haya funcionado para ti. – Eonasdan

+0

Esto me sirve. Gracias. – Dariusz

+0

¡Solucionado mi problema! – jray0039

Cuestiones relacionadas