I'm struggling with a framework 4.5 problem. Our asp.net mvc4 web app is running well on a 2008R2 server with .net 4.0 installed but when we upgrade the framework to .net 4.5 we seem to hit some kind of nasty bug:
Could not load type '...' from assembly '...' because the method '...' has no implementation (no RVA)
This unusual exception is thrown by the framework when getting a type using reflection from the asp.net generated .cs code of a .aspx view. We get a YSOD:
Server Error in '/' Application. Could not load type 'ASP.views_beherenecli_actielijstecli_index_aspx' from assembly 'App_Web_index.aspx.aeda16c.y-wvrppj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '__RenderContent3' has no implementation (no RVA). 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 'ASP.views_beherenecli_actielijstecli_index_aspx' from assembly 'App_Web_index.aspx.aeda16c.y-wvrppj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '__RenderContent3' has no implementation (no RVA).
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: [TypeLoadException: Could not load type 'ASP.views_beherenecli_actielijstecli_index_aspx' from assembly 'App_Web_index.aspx.aeda16c.y-wvrppj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '_RenderContent3' has no implementation (no RVA).] System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) +0 System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +73 System.Web.Compilation.BaseTemplateBuildProvider.GetGeneratedType(CompilerResults results, Boolean useDelayLoadTypeIfEnabled) +128 System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +103 System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +23 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +599 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +571 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +203 System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +249 System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +36 System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func
2 virtualPathExists) +55 System.Linq.WhereSelectListIterator
2.MoveNext() +245 System.Linq.Enumerable.FirstOrDefault(IEnumerable1 source, Func
2 predicate) +215 System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func2 virtualPathExists, IDisplayMode currentDisplayMode) +27 System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List
1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +402 System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +942 System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +206 System.Web.Mvc.<>c_DisplayClassc.b_b(IViewEngine e) +47 System.Web.Mvc.ViewEngineCollection.Find(Func2 lookup, Boolean trackSearchedPaths) +176 System.Web.Mvc.ViewResult.FindView(ControllerContext context) +110 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +147 System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func
1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +263 System.Web.Mvc.Async.<>c_DisplayClass25.b_22(IAsyncResult asyncResult) +240 System.Web.Mvc.<>c_DisplayClass1d.b_18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.<>c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.<>c_DisplayClass8.b_3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c_DisplayClass4.b__3(IAsyncResult ar) +15 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Question: Am I the only one with this problem? Does anyone know how to work around this or know a fix?
note: the code is compiled on a buildserver with framework 4.0. The problem seems really related to .Net 4.5 because when we downgrade to 4.0 the problem disappears.
Things we have tried:
- deleting Temporary ASP.NET files folder
- in web.config use the compilation element and targetFramework="4.5" attribute.