6
Server Error in '/' Application.

有什么好的方法可以解决这个问题?我让调试逐步检查 global.asax 中的所有内容,并且那里没有错误。

Operation could destabilize the runtime.

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.Security.VerificationException: Operation could destabilize the runtime.

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: 


[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) +199
   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.CreateHost() +51
   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
4

2 回答 2

4

尽管我的项目是.Net 4.5,但我遇到了完全相同的问题。我按照将 ASP.NET MVC 3 项目升级到 ASP.NET MVC 4 的步骤 7 解决了这个问题

复制到这里如下:

7.如果项目引用了任何使用以前版本的 ASP.NET MVC 编译的第三方库,打开根 Web.config 文件并在配置部分下添加以下三个 bindingRedirect 元素:

 <configuration>
  <!--... elements deleted for clarity ...-->

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" 
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" 
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" 
             publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
于 2013-06-11T01:50:42.990 回答
3

这是一件非常奇怪的事情 - 提供的信息不足以复制它......所以只是一些可能导致你看到的东西:

  • Intellitrace(关闭它,看看它是否有帮助)
  • 使用任何“旧控件”(尤其是 V 1.1),将它们注释掉,看看它是否有帮助
  • 信任级别,更改为[assembly: SecurityRules(SecurityRuleSet.Level1)]AssemblyInfo.cs 并查看是否有帮助

它也可能是.NET 4.5 运行时中的一个错误,它在安装时充当 .NET 4 运行时的直接替代品,即使您的代码仅针对 .NET 4 也可以使用!

从链接的文章中,Microsoft 已将 .Net 4.5/4.0 运行时的修复程序作为修补程序创建:http: //support.microsoft.com/kb/2748645

于 2012-08-31T17:15:46.473 回答