Alex Rivera | Logout

.NET - What's the best way to implement a "catch all exceptions handler"

Asked 2008-10-20T19:35:54.673
78

I'm wondering what the best way is to have a "if all else fails catch it".

I mean, you're handling as much exceptions as possible in your application, but still there are bound to be bugs, so I need to have something that catches all unhandled exceptions so I can collect information and store them in a database or submit them to a web service.

Does the AppDomain.CurrentDomain.UnhandledException event capture everything? Even if the application is multithreaded?

Side note: Windows Vista exposes native API functions that allow any application to recover itself after a crash... can't think of the name now... but I'd rather not use it, as many of our users are still using Windows XP.

Edit
Report

1 Answer

4

For WinForms, don't forget to attach to the current Thread's unhandled exception event too (especially if you are using multi threading).

Some links on best practices here and here and here (probably the best exception handling article for .net)

answered 2008-10-20T19:47:47.987

Your Answer