tags:

views:

858

answers:

1

[TypeLoadException: Could not load type 'System.Web.Mvc.AreaRegistration' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.] HemelMvc.MvcApplication.Application_Start() in D:\@Hemel\HemelMvc\src\HemelMvc\Global.asax.cs:72

[HttpException (0x80004005): Could not load type 'System.Web.Mvc.AreaRegistration' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +2723002 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +128 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295 System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231

[HttpException (0x80004005): Could not load type 'System.Web.Mvc.AreaRegistration' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8896063 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333


Got this error when copied ASP.NET MVC 2 RC application to shared hosting.

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterRoutes(RouteTable.Routes);
    }

Line 72 in Global.asax.cs is after >> RegisterRoutes(RouteTable.Routes);

Why is there reference to my local path on remote site?? D:\@Hemel\HemelMvc\src\HemelMvc\Global.asax.cs:72

+2  A: 

Local path info is stored in the PDB file which helps the VS debugger help you. You don't need to include it on your host and you should switch your project configuration to "Release" so it does not include all the extra debugging info.

BTW you're probably getting the "could not load type" error because the shared host doesn't have MVC2 installed.

AUSteve
I had this problem last night. I had MVC 2 Beta 2 on the server. I uninstalled the Beta and installed the RC. I still had to reboot the server before the code worked.
Martin
So if my hosting has Beta 2 installed can I override it with RC 2 somehow by coping newer dlls to bin ?? (tried this but does not work)
daniel
You would have to make sure your app is referencing the RC2 DLLs rather than the installed DLLs. Check the reference paths in the project file and web.config.
AUSteve
Could you please describe in more detail what exactly I need to look at and modify to ensure this ?
daniel
Think this is not possible since Beta 2 dll is has version number same as RC 2 (2.0.0.0) so GAC will always take precedence when loading assembly.
daniel
The Bin folder has precedence, then the GAC. Copy the RC2 DLLs to the Bin folder.
AUSteve