Improved Unhandled Exception behavior in .net 2.0
来源:互联网 发布:vb与c语言的区别 编辑:程序博客网 时间:2024/06/02 05:31
The first thing to understand is that the UnhandledException event is not an unhandled exception "handler". Registering for the event, contrary to what the documentation says :-(, does not cause unhandled exceptions to be handled. (Since then they wouldn't be unhandled, but I'll stop with the circular reasoning already...) The UnhandledException event simply notifies you that an exception has gone unhandled, in case you want to try to save state before your thread or application dies. FWIW, I have filed a bug to get the docs fixed.
Just to complicate things, in v1.0 and 1.1, an unhandled exception did not always mean that your application would die. If the unhandled exception occurred on anything other than the main thread or a thread that began its life in unmanaged code, the CLR ate the exception and allowed your app to keep going. This was generally evil, because what would often happen was, for example, that ThreadPool threads would silently die off, one by one, until your application wasn't actually doing any work. Figuring out the cause of this kind of failure was nearly impossible. This may be why Jeff thought it worked before...he just always saw crashes on non-main threads.
In v2.0, an unhandled exception on any thread will take down the application. We've found that it's tremendously easier to debug crashes than it is to debug hangs or the silent-stoppage-of-work problem described above.
BTW, on my 1.1 machine the example from MSDN does have the expected output; it's just that the second line doesn't show up until after you've attached a debugger (or not). In v2 we've flipped things around so that the UnhandledException event fires before the debugger attaches, which seems to be what most people expect.
Jonathan Keljo
CLR Exceptions PM
http://www.codinghorror.com/blog/archives/000216.h...
- Improved Unhandled Exception behavior in .net 2.0
- unhandled exception in:0xC0000005:Acess Violation
- Managing Unhandled Exceptions in .NET
- Managing Unhandled Exceptions in .NET
- unhandled exception
- Unhandled exception in XX.exe:oxc0000005:access violation 错误调试
- An unhandled win32 exception occurred in explored.exe[1108]
- unhandled exception in .exe :0xC0000005:Access Violation.
- unhandled exception in *.exe (MFC42D.DLL):0xC0000005:Access Violation
- Unhandled exception in XX.exe:0xC0000005:Access Violation”
- 奇怪的 unhandled exception in 0xc0000005 *.exe:、错误
- unhandled exception in MSDEV.EXE(DEVSHL.DLL) :0xC0000005
- Unhandled exception at 0x in xxx.exe: Privileged instruction.
- unhandled exception in XXX:0xC0000005:access violation问题
- Unhandled exception at 0x51be3eb5 (RuntimeLib_DX11.dll) in XXXX.exe
- Unhandled exception in ***.exe(OLE32.DLL):0xC0000005:Access Violation
- opencv imread imwrite "Unhandled exception in ***.exe(msvcr100d.dll):OxC0000005"
- MFC调试出错:Unhandled exception in 0xC0000005:Access Violation
- ◎VBS编程打造自己的病毒专杀工具
- Ctrl+Enter提交事件
- XML文件的读取用XmlDocument和XmlReader的比较
- __cdecl,__fastcall, __stdcall 什么区别?
- C++ Builder VCL库函数简介
- Improved Unhandled Exception behavior in .net 2.0
- 互联网的未来在中国,中国未来的互联网在我们
- delphi汉字首字母索引函数
- 现自定义page基类时需要注意的地方
- 使用C#操作ini文件
- ◎VBS脚本运行库手册之二 ——管理文件夹
- ubuntu 终于出声了
- ◎Vbs脚本编程简明教程之十六——访问ADO数据库
- 第一次