1

我正在努力解决框架 4.5 的问题。我们的 asp.net mvc4 Web 应用程序在安装了 .net 4.0 的 2008R2 服务器上运行良好,但是当我们将框架升级到 .net 4.5 时,我们似乎遇到了某种令人讨厌的错误:

无法从程序集“...”加载类型“...”,因为方法“...”没有实现(无 RVA)

当从 asp.net 生成的 .aspx 视图的 .cs 代码中使用反射获取类型时,框架会引发此异常异常。我们得到一个 YSOD:

“/”应用程序中的服务器错误。 无法从程序集 'App_Web_index.aspx.aeda16c.y-wvrppj,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null' 加载类型 'ASP.views_beherenecli_actielijstecli_index_aspx',因为方法 '__RenderContent3' 没有实现(无 RVA)。 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.TypeLoadException:无法从程序集“App_Web_index.aspx.aeda16c.y-wvrppj”加载类型“ASP.views_beherenecli_actielijstecli_index_aspx”,版本=0.0.0.0,文化=中性,PublicKeyToken=null,因为方法“__RenderContent3”具有没有实施(没有 RVA)。

源错误:在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。

堆栈跟踪:[TypeLoadException:无法从程序集“App_Web_index.aspx.aeda16c.y-wvrppj,版本=0.0.0.0,文化=中性,PublicKeyToken=null”加载类型“ASP.views_beherenecli_actielijstecli_index_aspx”,因为方法“_RenderContent3' 没有实现(无 RVA)。] System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly 程序集,字符串名称,布尔 throwOnError,布尔 ignoreCase,ObjectHandleOnStack 类型)+0 System.Reflection.RuntimeAssembly.GetType(字符串名称,布尔 throwOnError, Boolean ignoreCase) +73 System.Web.Compilation.BaseTemplateBuildProvider.GetGeneratedType(CompilerResults 结果, Boolean useDelayLoadTypeIfEnabled) +128 System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults 结果) +103 System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults 结果) +23 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +599 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild,布尔allowCrossApp,布尔allowBuildInPrecompile,布尔throwIfNotFound,布尔ensureIsUpToDate)+571 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext上下文,VirtualPath virtualPath,布尔noBuild,布尔allowCrossApp,布尔allowBuildInPrecompile,布尔throwIfNotFound,布尔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, FuncBoolean 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 上下文, 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 , 功能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 上下文, 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 , 功能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, FuncBoolean 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, FuncWebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, FuncWebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func2 virtualPathExists) +55 System.Linq.WhereSelectListIterator2.MoveNext() +245 System.Linq.Enumerable.FirstOrDefault(IEnumerable 1 source, Func2 谓词) +215 System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func 2 virtualPathExists, IDisplayMode currentDisplayMode) +27 System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List1 位置, 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(Func 2 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, Func1 继续) +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

问题:我是唯一有这个问题的人吗?有谁知道如何解决这个问题或知道修复?

注意:代码是在带有框架 4.0 的构建服务器上编译的。这个问题似乎真的与 .Net 4.5 有关,因为当我们降级到 4.0 时,问题就消失了。

我们尝试过的事情:

  • 删除临时 ASP.NET 文件夹
  • 在 web.config 中使用编译元素和 targetFramework="4.5" 属性。
4

2 回答 2

1

在 HTML 帮助方法中使用 C#“动态”关键字似乎是问题的根源。主渲染方法的 RVA 值为 0,这导致“方法没有实现(无 RVA)异常”。当 asp.net 尝试解析包含该方法的类型时出错。

于 2013-01-17T13:20:33.373 回答
0

看看这个:

将 ASP.NET MVC 应用程序的目标框架从 4.0 升级到 4.5

将 ASP.NET MVC 4 应用程序从 .NET 4.0 升级到 .NET 4.5 框架并非易事。

于 2013-01-17T11:44:15.520 回答