Application.SetUnhandledExceptionMode Method (UnhandledExceptionMode)

Note: This method is new in the .NET Framework version 2.0.

Instructs the application how to respond to unhandled exceptions.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public static void SetUnhandledExceptionMode (
	UnhandledExceptionMode mode
public static void SetUnhandledExceptionMode (
	UnhandledExceptionMode mode
public static function SetUnhandledExceptionMode (
	mode : UnhandledExceptionMode



An UnhandledExceptionMode value describing how the application should behave if an exception is thrown without being caught.

Exception typeCondition


You cannot set the exception mode after the application has created its first window.

It is often not feasible to catch all of the exceptions thrown by an application. Using this method, you can instruct your application whether it should catch all unhandled exceptions and continue operating, or whether it should expose them to the user and halt execution.

Call SetUnhandledExceptionMode before you instantiate the main form of your application using the Run method.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0