在执行当前Web请求期间发生了未处理的异常

时间:2013-01-19 15:03:00

标签: c# asp.net exception-handling hresult

突然,当我运行我的Web应用程序时,我收到此错误:

  

无法加载文件或程序集   'file:/// C:\ Users \ rafael \ AppData \ Local \ Temp \ Temporary ASP.NET   文件\ ROOT \ 284bddf3 \ 431c8965 \ App_Web_homepage.aspx.cdcab7d2.vmizb1js.dll”   或其中一个依赖项。句柄无效。 (例外   HRESULT:0x80070006(E_HANDLE))

这是堆栈跟踪:

FileLoadException: Could not load file or assembly 'file:///C:\Users\rafael\AppData\Local\Temp\Temporary ASP.NET Files\root\284bddf3\431c8965\App_Web_homepage.aspx.cdcab7d2.vmizb1js.dll' or one of its dependencies. The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) +28
   System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() +93
   System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +60
   System.Web.Compilation.TemplateControlBuildProvider.CreateBuildResult(CompilerResults results) +36
   System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +16
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +9086138
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +320
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +111
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +125
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +52
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
   System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +167
   System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +517

[HttpException (0x80004005): Error executing child request for /homepage.aspx.]
   System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +816
   System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) +57
   System.Web.HttpServerUtility.Transfer(String path) +32
   photography.Global.Application_BeginRequest(Object sender, EventArgs e) in F:\Web Prog\my work\mcpd\gallery\photography\photography\Global.asax.cs:27
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

我不知道它到底是什么。如果我得到任何帮助,我将不胜感激。

2 个答案:

答案 0 :(得分:1)

您可以选择stop and restart the website吗?

理论上,这应该是recycle the application pool for your site,这可能足以解决问题。

我希望这会对你有所帮助。

答案 1 :(得分:0)

在您的服务器上执行以下操作:

  1. 打开命令提示符并运行以下命令:
  2. C:\ WINDOWS \ Microsoft.NET.NET Framework \ Framework Version \ aspnet_regiis.exe -i
  3. .NET框架版本可以替换为应用程序项目的.NET框架。 v2.0.50727或4.0 e.t.c

    再次尝试运行该应用程序,你会没事的。