Defines where a Windows Forms application should send unhandled exceptions.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
|Route all exceptions to the ThreadException handler, unless the application's configuration file specifies otherwise.|
|Always route exceptions to the ThreadException handler. Ignore the application configuration file.|
|Never route exceptions to the ThreadException handler. Ignore the application configuration file.|
This enumeration is used by SetUnhandledExceptionMode.
In the .NET Framework version 2.0, the common language runtime behavior changed to allow unhandled exceptions to propagate up the call stack. This behavior can be disabled via the application configuration file. For more information, see Exceptions in Managed Threads.
The following code example sets event handlers for both errors that occur on Windows Forms threads and errors that occur on other threads. It sets SetUnhandledExceptionMode so that all errors are handled by the application, regardless of the settings in the application's user configuration file. It uses the ThreadException event for the former, and the UnhandledException event for the latter. Since UnhandledException cannot prevent an application from terminating, the example simply logs the error in the system Event Log prior to termination.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.