Updating to Microsofts ASP.NET Razor Update 3.2.0, Web Pages 3.2.0, MVC 5.2.0 with nuget causes Exception

Hello,

after updating Microsofts ASP.NET Razor Update 3.2.0, Web Pages 3.2.0, MVC 5.2.0 with nuget i immediately get the following exception on starting the mvc project:

System.MissingMethodException: Method not found: "Boolean System.Web.WebPages.BuildManagerWrapper.IsNonUpdateablePrecompiledApp(System.Web.Hosting.VirtualPathProvider, Microsoft.Internal.Web.Utils.IVirtualPathUtility)".

   bei System.Web.Mvc.BuildManagerViewEngine.GetPrecompiledNonUpdateable()
   bei System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   bei System.Threading.LazyInitializer.EnsureInitialized[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   bei System.Web.Mvc.BuildManagerViewEngine.get_IsPrecompiledNonUpdateableSite()
   bei System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath)
   bei System.Web.Mvc.VirtualPathProviderViewEngine.<>c__DisplayClass7.<GetPathFromGeneralName>b__3(String path)
   bei System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func`2 virtualPathExists)
   bei System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode)
   bei System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode)
   bei System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations)
   bei System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]&
searchedLocations)
   bei System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache)
   bei System.Web.Mvc.ViewEngineCollection.<>c__DisplayClass6.<FindView>b__5(IViewEngine e)
   bei System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
   bei System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator)
   bei System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName)
   bei System.Web.Mvc.ViewResult.FindView(ControllerContext context)
   bei System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   bei System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   bei System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   bei System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   bei System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   bei System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   bei System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   bei System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   bei System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   bei System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
   bei System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   bei System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   bei System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   bei System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   bei System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   bei System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   bei System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thanks Martin

Clean/Rebuild Solution. Make sure all your projects using the same nuget version(better if you remove and re-add). Try adding bindingRedirect,

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>

In addition to what imran_ku07 mentioned above, include the below (just to be sure)

      <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

Thanks for your replys,

- readded nuget to project

- cleaned and rebuild project

web.config before update (working):

    <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
      </dependentAssembly>

after update (not working, causes error):

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

changed to (not working, still causes error):

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

The entry "System.Web.WebPages.Razor" does not exist and was added.

Sorry, but i get the same error again.

Thanks Martin

Can you reproduce and share a sample?

I am also getting this exact same error, I cannot share a sample in this case.  Going insane over here though.

Can you check your Views/Web.config,

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0,

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral

Same error though.  It looks like that method was added in latest System.Web.WebPages.  I have removed and readded the references a dozen times, is it possible Nuget has the wrong assembly?  I assume it works for other people, which means that is likely
not the case…

I have compared both MVC(5.1 and 5.2) and Web Pages(3.1 and 3.2) nuget packages and found that
only MVC 5.2 is calling IsNonUpdateablePrecompiledApp which is
only
exist in Web Pages 3.2. Note that Web Pages 3.1 and 3.2 has the same 3.0.0.0 dll version. Check references, remove the System.Web.WebPages reference and add a reference from
‘YourSolutionackagesMicrosoft.AspNet.WebPages.3.2.0libnet45System.Web.WebPages.dll’. If you have multi projects the do it for all where you reference mvc

Same error, although it appears the dll shipped in that folder is still the outdated version.  Replaced it with "…packagesMicrosoft.AspNet.WebPages.3.2.0libnet45System.Web.WebPages.dll", claims to be the v3.0.0 dll version still.  Is there somewhere
I can get a compiled binary other than nuget?

I have checked, it is working with me. You can decompile the dll using JustDecompile or IlSpy and check the method IsNonUpdateablePrecompiledApp inside System.Web.WebPages.BuildManagerWrapper class

Fixed, deleted the shadow copy of the old assembly.

Can you tell me please how you fixed the problem?

Thanks Martin

How can i fix the Problem without decompiling any assemblies? A new created Project seems not so have any Problems in updating to the new Version.

Can you please delete the files in XX:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Files and XX:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Files.

Thi is what a asimpleuser is saying

Thanks for your reply, this folder ist empty.

I copied the folder to another name (Project->Project1) to check if the project works if i update. With the renamed folder the project works with the update, but if i rename the folder back from (Project1->Project) the error occurs again.

I deleted the Project.v12.suo File with no success.

Any Ideas?

You can create a new MVC 5.2 app and copy paste your existing controller, views there to make your life easy.

I know, but the solution has about 2000 Files and Folders, i don’t want to transfer them all if there is another way. Is there any reason why the changed project path leads to a working solution?

The probelm you are referencing the dll somewhere but you are unable to find this. Check Tools Debug > Modules window to see what dlls are loading and from where.

o.k. i found the following directories in den modules:

    System.Web.Helpers.dll    C:UsersmartinzimAppDataLocalTempTemporary ASP.NET Filesrootbbe521d9da394261assemblydl3d11186987b9e9d89_e999cf01System.Web.Helpers.dll 3.00.20627.0
    System.Web.Mvc.dll    C:UsersmartinzimAppDataLocalTempTemporary ASP.NET Filesrootbbe521d9da394261assemblydl36d80a11ec90cbf89_e999cf01System.Web.Mvc.dll 5.02.20627.0
    System.Web.Razor.dll    C:UsersmartinzimAppDataLocalTempTemporary ASP.NET Filesrootbbe521d9da394261assemblydl378ec5bc853e88289_e999cf01System.Web.Razor.dll 3.00.20627.0

I cleared the directory and rebuilded all, if i use the renamed directory it works, if i rename it back it fails.

The references in the project point to:

- packagesMicrosoft.AspNet.Mvc.5.2.0libnet45System.Web.Mvc.dll

- packagesMicrosoft.AspNet.Razor.3.2.0libnet45System.Web.Razor.dll

- packagesMicrosoft.AspNet.WebPages.3.2.0libnet45System.Web.Helpers.dll

I was able to fix this by getting the latest MVC 5.2.2 using NuGet. Once installed, delete the content of obj/Release and obj/Debug in your solution then rebuild, this will make sure that new package will be created using the new version of MVC. Cheers :) 

Leave a Reply