0
votes

What causes this error on a WebMvc application?

Attempt by method 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(System.Web.Mvc.ControllerContext, System.String[], System.String[], System.String, System.String, System.String, System.String, Boolean, System.String[] ByRef)' 

to access method 'System.Web.Mvc.VirtualPathProviderViewEngine.get_DisplayModeProvider()' failed.

Server Error in '/' Application.

Attempt by method 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(System.Web.Mvc.ControllerContext, System.String[], System.String[], System.String, System.String, System.String, System.String, Boolean, System.String[] ByRef)' to access method 'System.Web.Mvc.VirtualPathProviderViewEngine.get_DisplayModeProvider()' failed. 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.MethodAccessException: Attempt by method 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(System.Web.Mvc.ControllerContext, System.String[], System.String[], System.String, System.String, System.String, System.String, Boolean, System.String[] ByRef)' to access method 'System.Web.Mvc.VirtualPathProviderViewEngine.get_DisplayModeProvider()' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[MethodAccessException: Attempt by method 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(System.Web.Mvc.ControllerContext, System.String[], System.String[], System.String, System.String, System.String, System.String, Boolean, System.String[] ByRef)' to access method 'System.Web.Mvc.VirtualPathProviderViewEngine.get_DisplayModeProvider()' failed.] System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +692 System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +315 System.Web.Mvc.<>c__DisplayClassc.b__a(IViewEngine e) +68 System.Web.Mvc.ViewEngineCollection.Find(Func2 lookup, Boolean trackSearchedPaths) +182 System.Web.Mvc.ViewEngineCollection.Find(Func2 cacheLocator, Func2 locator) +67 System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName) +329 System.Web.Mvc.ViewResult.FindView(ControllerContext context) +135 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +230 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39 System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +74 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +388 System.Web.Mvc.<>c__DisplayClass1c.b__19() +72 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +303 System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +155 System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +184 System.Web.Mvc.Async.WrappedAsyncResult1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +40 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +47 System.Web.Mvc.Async.WrappedAsyncResult1.End() +151 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47 System.Web.Mvc.Async.WrappedAsyncResult1.End() +151 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +45 System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +47 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690164 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

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

2
The error happens on start-up. The application compiles but cannot open any pages. This is a site that I'm upgrading from VS2010 to VS2013. I updated some of the MVC libraries.Adam Mendoza

2 Answers

1
votes

What causes this error on a WebMvc application?

Hmmm... I wonder...

I updated some of the MVC libraries.

Well, there you go. What you have basically done is walked into a doctors office and said "Doctor, I cannot figure out why I have this terrible pain in my arm", to which the doctor replies "Did you do anything to it?" and you respond, "I only stabbed it with a knife 143 times....."

First of all, you can't just update libraries. Upgrading MVC has a process you must go through.

http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

Secondly, even if you were going to update the libraries, you can't just upgrade "some" of them. These libraries are all dependent on each other, and upgrading some without the others will cause many problems.

There's a lot of configuration that has to get updated, as well as keeping the various DLL's in sync. Not to mention, going from VS2010 to 2013 means uninstalling packages that were targeting .net 4 and installing the 4.5 versions...

0
votes

In your project right click and choose "Manage NuGet Packages", in opened box on right side, select the option "Online" and will appear "Microsoft ASP.NET MVC" install it. This solved my problem.