您的位置:首页 > 编程语言 > ASP

Asp.net 2.0的异常处理需要考虑的问题

2008-05-13 14:56 375 查看
Asp.net 2.0的异常处理需要考虑的问题

在.NET 1.1, 只有主线程中未处理的异常才会终止应用程序的运行,其他的线程的异常.CLR会处理,因此你的应用程序可以正常运行.在 .NET 2.0, 任何线程上的未处理的异常都可能终止应用程序的运行 (具体信息参看

Exceptions In Managed Threads

). 这对于Asp.net开发者来说,特别在将1.1程序升级到2.0的时候需要特别注意这点,如果你的程序中对异常处理有统一的策略,所有的异常都进行了处理.那非常不错.不然你的程序的异常处理可能就会带来致命的问题.

可以参照.

Exceptions in Managed Threads

In the .NET Framework version 2.0, the common language runtime allows most unhandled exceptions in threads to proceed naturally. In most cases this means that the unhandled exception causes the application to terminate.

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

Asp.Net 异常处理

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

引用
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.

或者

ASP.NET 2.0 Unhandled Exception Issues

的方法解决

另外推荐一个 .NET USB开发方面的一个开源项目

.NET 包含的基类库 (BCL) 不支持与 USB 设备进行会话。大多数情况下,如果要从 .NET 访问 USB 设备,需要使用设备制造商提供的高级类库。这是一个

SourceForge

上的开源项目。MSDN中的介绍文章:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: