您的位置:首页 > 移动开发

Unhandled exceptions cause ASP.NET-based applications to unexpectedly quit in the .NET Framework 2.0

2006-04-01 23:52 1071 查看

SYMPTOMS

When an unhandled exception is thrown in a Microsoft ASP.NET-based application that is built on the Microsoft .NET Framework 2.0, the application unexpectedly quits. When this problem occurs, no exception information that you must have to understanding the issue is logged in the Application log.

However, an event message that is similar to the following may be logged in the System log:
Event Type: Warning
Event Source: W3SVC
Event Category: None
Event ID: 1009
Date: 9/28/2005
Time: 3:18:11
PM User: N/A
Computer: IIS-SERVER
Description:
A process serving application pool ‘DefaultAppPool’ terminated unexpectedly. The process id was ‘2548’. The process exit code was ‘0xe0434f4d’.
Additionally, an event message that is similar to the following may be logged in the Application log:
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 9/28/2005
Time: 3:18:02 PM
User: N/A
Computer: IIS-SERVER
Description:
EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4 app_web_7437ep-9, P5 0.0.0.0, P6 433b1670, P7 9, P8 a, P9 system.exception, P10 NIL.

CAUSE

This problem occurs because the default policy for unhandled exceptions has changed in the .NET Framework 2.0. By default, the policy for unhandled exceptions is to end the worker process.

In the Microsoft .NET Framework 1.1 and in the Microsoft .NET Framework 1.0, unhandled exceptions on managed threads were ignored. Unless you attached a debugger to catch the exception, you would not realize that anything was wrong.

ASP.NET uses the default policy for unhandled exceptions in the .NET Framework 2.0. When an unhandled exception is thrown, the ASP.NET-based application unexpectedly quits.

This behavior does not apply to exceptions that occur in the context of a request. These kinds of exceptions are still handled and wrapped by an HttpException object. Exceptions that occur in the context of a request do not cause the worker process to end. However, unhandled exceptions outside the context of a request, such as exceptions on a timer thread or in a callback function, cause the worker process to end.

RESOLUTION

Change the unhandled exception policy back to the default behavior that occurs in the .NET Framework 1.1 and in the .NET Framework 1.0.

Note We do not recommend that you change the default behavior. If you ignore exceptions, the application may leak resources and abandon locks.

To enable this default behavior, add the following code to the Aspnet.config file that is located in the following folder:
%WINDIR%/Microsoft.NET/Framework/v2.0.50727
[code]<configuration>
<runtime>
<legacyUnhandledExceptionPolicy enabled="true" />
</runtime>
</configuration>

当然还有种方法,复杂多,不推荐,也就不贴出来了

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐