2013-01-17 79 views
1

我正在努力解決一個框架4.5的問題。我們asp.net mvc4的web應用程序安裝.NET 4.0 2008R2服務器上運行良好,但是當我們升級框架.NET 4.5我們似乎打某種討厭的錯誤的:.Net 4.5與MVC4的錯誤

Could not load type '...' from assembly '...' because the method '...' has no implementation (no RVA)

這種不尋常的例外是當使用asp.net生成的.aspx視圖的.cs代碼中的反射獲取類型時,由框架拋出。我們得到一個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(IEnumerable 1 source, Func 2 predicate) +215 System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func 2 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(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, 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

問:我是唯一一個有這個問題?有誰知道如何解決這個問題或知道修復?

注意:該代碼是在帶有framework 4.0的buildserver上編譯的。這個問題似乎與.Net 4.5真正相關,因爲當我們降級到4.0時,問題就消失了。

的事情,我們曾嘗試:

  • 刪除臨時ASP.NET文件的文件夾
  • 在web.config中使用編譯元素和targetFramework = 「4.5」 屬性。
+0

我不認爲你的問題是一個錯誤.. –

+0

隨着ILDASM我們驗證了有問題的程序集DLL,並注意到方法__RenderContent3的RVA值的值爲0x00000000。這意味着該方法沒有實現。如果我們看到生成的.cs這個方法肯定有很多代碼在裏面......沒問題的程序集沒有RVA值爲0x00000000,所以這必須是當asp.net將視圖編譯成DLL的時候發生的一些錯誤。 –

回答

0

看看這個:

Upgrading target framework from 4.0 to 4.5 for ASP.NET MVC applications

從.NET 4.0的升級ASP.NET MVC 4應用程序.NET 4.5框架是不容易的事。

+0

鏈接建議將代碼庫升級到4.5,但我們無法升級我們的代碼庫,而是在vs2010中開發併爲fw4.0構建。我認爲可以在4.5運行時運行4.0程序集? (因爲MS說幾乎沒有變化) –

1

在HTML助手方法中使用C#「dynamic」關鍵字似乎是問題的根源。主要的render方法得到的RVA值爲0,導致「Method has no implementation(No RVA)exception」。 asp.net嘗試解析包含該方法的類型時發生錯誤。

+1

嗨,鮑里斯,你可以給我們發電子郵件給[email protected]的這個問題嗎?謝謝!這看起來不像MVC特定的問題。它更像編譯期間的CLR問題。 – Anand

+0

會這樣做:-) –