Windows Presentation Foundation

Sentry's .NET SDK works with Windows Presentation Foundation applications through the Sentry NuGet package. It works with WPF apps running on .NET Framework 4.6.1, .NET Core 3.0 or higher.


In addition to initializing the SDK with SentrySdk.Init, you must configure the WPF specific error handler.

The SDK automatically handles AppDomain.UnhandledException. On WPF, for production apps (when no debugger is attached), WPF catches exception to show the dialog to the user. You can also configure your app to capture those exceptions before the dialog shows up:

using System.Windows;

public partial class App : Application
    public App()
        DispatcherUnhandledException += App_DispatcherUnhandledException;

    void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)

        // If you want to avoid the application from crashing:
        e.Handled = true;
You can edit this page on GitHub.