Back to Devexpress

WinApplication.CustomHandleException Event

expressappframework-devexpress-dot-expressapp-dot-win-dot-winapplication-72cd5817.md

latest3.4 KB
Original Source

WinApplication.CustomHandleException Event

Occurs before displaying a message box with an exception message.

Namespace : DevExpress.ExpressApp.Win

Assembly : DevExpress.ExpressApp.Win.v25.2.dll

NuGet Packages : DevExpress.ExpressApp.Win, DevExpress.ExpressApp.Win.Design

Declaration

csharp
public event EventHandler<CustomHandleExceptionEventArgs> CustomHandleException
vb
Public Event CustomHandleException As EventHandler(Of CustomHandleExceptionEventArgs)

Event Data

The CustomHandleException event's data class is CustomHandleExceptionEventArgs. The following properties provide information specific to this event:

PropertyDescription
ExceptionGets the exception that occurred.
HandledGets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
OriginalExceptionGets the original exception.

Remarks

Raised as the result of executing the WinApplication.HandleException method. Handle the CustomHandleException event to customize the exceptions processing in a Windows Forms application. Place a custom code in this event handler, and it will be executed before the message box is shown. The exception that occurs is accessible via the Exception parameter. You can set the handler’s Handled parameter, to prohibit displaying the default message box.

csharp
static class Program {
    static void Main() {
        // ...
        MySolutionWindowsFormsApplication winApplication = 
            new MySolutionWindowsFormsApplication();
        //...
        winApplication.CustomHandleException += winApplication_CustomHandleException;
        // ...
        try {
            winApplication.Setup();
            winApplication.Start();
        }
        catch (Exception e) {
            winApplication.HandleException(e);
        }
    }
    // ...
    static void winApplication_CustomHandleException(
        object sender, CustomHandleExceptionEventArgs e) {
        // Place your code here. Set e.Handled to true to prohibit displaying default message box.
    }
}

See Also

WinApplication Class

WinApplication Members

DevExpress.ExpressApp.Win Namespace