Why the form load can’t catch exception?

Rewrite, I’ve since figured out where it comes from. Windows misbehaves when an exception is raised in a 32-bit process when it runs on a 64-bit version of Windows 7. It swallows any exception raised by code that runs in response to a Windows message that’s triggered by the 64-bit windows manager. Like WM_SHOWWINDOW, the message that causes the Load event to get raised.

The debugger plays a role because when it is active, normal exception trapping in a Winforms app is turned off to allow the debugger to stop on an exception. That doesn’t happen in this scenario because Windows 7 swallows the exception first, preventing the debugger from seeing it.

I’ve written about this problem more extensively in this answer, along with possible workarounds.

Leave a Comment