System.Windows.Forms.Application.SetUnhandledExceptionMode Method

Instructs the application how to respond to unhandled exceptions.

Syntax

public static void SetUnhandledExceptionMode (UnhandledExceptionMode mode)

Parameters

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

Remarks

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

Call Application.SetUnhandledExceptionMode(UnhandledExceptionMode) before you instantiate the main form of your application using the erload:System.Windows.Forms.Application.Run method.

To catch exceptions that occur in threads not created and owned by Windows Forms, use the AppDomain.UnhandledException event handler.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0