操作可能会破坏mvc3 razor中的运行时稳定性

时间:2013-01-09 06:55:35

标签: asp.net-mvc-3

我在mvc3 razor工作我的项目正确运行但我收到了错误

Error   3   Assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral,     PublicKeyToken=31bf3856ad364e35' uses 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral,     PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced     assembly 'System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'        c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Mvc.dll    MvcApplication1

我将system.web.mvc.dll和System.Web.WebPages.Razor文件从mvc4文件夹替换为mvc3文件夹。和web.config中的一些更改,它开始正常工作。但现在几天后它会显示以下错误消息

操作可能会破坏运行时的稳定性

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Security.VerificationException:操作可能会破坏运行时的稳定性。

来源错误:

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

Stack Trace: 


[VerificationException: Operation could destabilize the runtime.]
System.Web.Mvc.Razor.MvcWebPageRazorHost.GetRidOfNamespace(String ns) +32
System.Web.Mvc.Razor.MvcWebPageRazorHost..ctor(String virtualPath, String physicalPath) +196
System.Web.Mvc.MvcWebRazorHostFactory.CreateHost(String virtualPath, String physicalPath) +113
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfigCore    (RazorWebSectionGroup        config, String virtualPath, String physicalPath) +422
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath, String physicalPath) +228
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath) +38
System.Web.WebPages.Razor.RazorBuildProvider.GetHostFromConfig() +51
System.Web.WebPages.Razor.RazorBuildProvider.CreateHost() +57
System.Web.WebPages.Razor.RazorBuildProvider.get_Host() +56
System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() +92
System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType() +54
System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +59
System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +209
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +15
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +9929933
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +33
System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +40
System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) +54
System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List1     
locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +197
System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String   controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +681
System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext,  String     viewName, String masterName, Boolean useCache) +315
System.Web.Mvc.<>c__DisplayClassc.<FindView>b__b(IViewEngine e) +68
System.Web.Mvc.ViewEngineCollection.Find(Func2 lookup, Boolean trackSearchedPaths) +182
System.Web.Mvc.ViewEngineCollection.Find(Func2 cacheLocator, Func2 locator) +110
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__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +74
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, 
Func1 continuation) +388
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +72
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext,IList1filters, ActionResult actionResult) +303
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +844
System.Web.Mvc.Controller.ExecuteCore() +130
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +229
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +71
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +44
System.Web.Mvc.Async.<>c__DisplayClass8
1.<BeginSynchronous>b__7(IAsyncResult _) +42
System.Web.Mvc.Async.WrappedAsyncResult
1.End() +152
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.<>c__DisplayClasse.<EndProcessRequest>b__d() +75
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +31
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +61
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +118
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
我的web.config中的

设置如下

<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
 <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>

请任何人给我这方面的帮助。

2 个答案:

答案 0 :(得分:0)

您是否安装了.NET Framework 4.5或Visual Studio 2012?问题很可能是框架中的错误。你可以在这里找到答案:

http://elegantcode.com/2012/08/23/net-4-5-operation-could-destabilize-the-runtime-yikes/

答案 1 :(得分:0)

我们的一个项目遇到了类似的问题。我们一直在使用MVC3并尝试升级到MVC4。我们还升级到了Razor 2.0。原来,web.configs没有按预期更新。检查〜/ Views文件夹中的web配置以及根web.config并确保程序集绑定重定向正确且所有程序集引用都正确。我们这样做了,问题就消失了