AccessViolationException,IIS

我们是4个开发人员(不是专业的服务器pipe理员),运行2个IIS 8.5(Windows Server 2012 R2)和ASP.NET 4的服务器。

每天多次我们在Windows事件日志中得到这个exception:

Application: w3wp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at System.Web.Hosting.UnsafeIISMethods.MgdIsLastNotification(IntPtr, System.Web.RequestNotificationStatus) at System.Web.Hosting.UnsafeIISMethods.MgdIsLastNotification(IntPtr, System.Web.RequestNotificationStatus) at System.Web.HttpRuntime.FinishRequestNotification(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext, System.Web.RequestNotificationStatus ByRef) at System.Web.HttpRuntime.OnRequestNotificationCompletionHelper(System.IAsyncResult) at System.Web.HttpRuntime.OnRequestNotificationCompletion(System.IAsyncResult) at System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception) at System.Web.HttpApplication+CallHandlerExecutionStep.OnAsyncHandlerCompletion(System.IAsyncResult) at System.Threading.Tasks.Task.Execute() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) at System.Threading.Tasks.Task.ExecuteEntry(Boolean) at System.Threading.ThreadPoolWorkQueue.Dispatch() 

事件日志中的下一个条目是这样的:

 Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x5215df96 Faulting module name: iiscore.dll, version: 8.5.9600.17224, time stamp: 0x53b1e5a1 Exception code: 0xc0000005 Fault offset: 0x0000000000002c44 Faulting process id: 0x257c Faulting application start time: 0x01d05f0c93813e6e Faulting application path: c:\windows\system32\inetsrv\w3wp.exe Faulting module path: C:\Windows\system32\inetsrv\iiscore.dll Report Id: 073f9a19-cb13-11e4-80c3-0cc47a02ce53 Faulting package full name: Faulting package-relative application ID: 

总是作为一对出现。 我花了几个小时与谷歌,但不知道这是否是在我们的代码或外部模块中的问题,以及如何解决。 主要的问题是我们的一台服务器不时响应,所以我真的很感兴趣,如果这个问题属于一起。

我们logging所有例外情况,但在日志中找不到。 我也尝试附加远程debugging器,但我没有得到exception,debugging真的减慢了网站。


编辑:我检查了所有的来源,以在m应用程序中捕获exception:

  • AppDomain.CurrentDomain.UnhandledException
  • TaskScheduler.UnobservedTaskException
  • 自定义的Owin中间件

但我找不到这个例外。 接下来我要尝试的是一个自定义http模块。 让我们来看看。

我还发现了一些事件日志中没有警告,如:

 Exception type: HttpException Exception message: The remote host closed the connection. The error code is 0x80070057. 

要么

 Exception type: HttpException Exception message: A potentially dangerous Request.Path value was detected from the client (:). 

这些可以经常发生,我很困惑为什么他们被添加到事件日志中。

这可能是一个ASPNET访问问题。

右键单击“计算机” – >“pipe理” – >“本地用户和组” – >“组”

find“DB2ADMNS”和“DB2USERS”组。

将“ASPNET”用户添加到每个组。

我不会在意的

exceptiontypes:HttpExceptionexception消息:远程主机closures连接。 错误代码是0x80070057。

这只是意味着远程端在接收数据的时候就走了(失去连接?谁知道呢)。

我也不会担心

exceptiontypes:HttpExceptionexception消息:从客户端(:)中检测到潜在危险的Request.Path值。

这只意味着你的URL包含一个冒号,这是不允许的。

所以这留下了前两个错误消息。 问题是在您的自定义应用程序的某处。

exception代码:0xc0000005

是访问冲突。 您的应用程序的帐户无法访问所需的所有内容(应用程序池?文件?)或尝试访问受保护的内存。 (在这个问题上有人build议,这个问题也可能是错误的内存。) debugging诊断 (和/或内存testing工具)可能可以帮助您追查是什么原因导致的问题。

祝你好运!