Another thing that’s been kicking around for awhile and I figured it was time to persist to long-term storage. Here are the three top-level places in a WinForms app where you absolutely need exception handling routines to ensure that all exceptions are caught:
- try/catch around Main()
- Attach a System.Threading.ThreadExceptionEventHandler to Application.ThreadException
- Attach a UnhandledExceptionEventHandler to AppDomain.CurrentDomain.UnhandledException
Note that simply having a try/catch around Main() is insufficient as you will not catch exceptions that occur during the execution of event handlers or asynchronous callbacks.