---
title: "WPF"
description: "Learn more about how Sentry's .NET SDK works with Windows Presentation Foundation (WPF) applications."
url: https://docs.sentry.io/platforms/dotnet/guides/wpf/
---

# WPF | Sentry for WPF

Sentry's .NET SDK works with Windows Presentation Foundation applications through the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). It works with WPF apps running on .NET Framework 4.6.2, .NET Core 3.0 or higher.

## [Features](https://docs.sentry.io/platforms/dotnet/guides/wpf.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## [Install](https://docs.sentry.io/platforms/dotnet/guides/wpf.md#install)

Error Monitoring\[ ]Tracing

Install the **NuGet** package to add the Sentry dependency:

```shell
dotnet add package Sentry -v 6.3.2
```

## [Configure](https://docs.sentry.io/platforms/dotnet/guides/wpf.md#configure)

In addition to [initializing the SDK with `SentrySdk.Init`](https://docs.sentry.io/platforms/dotnet.md), 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:

```csharp
using System.Windows;

public partial class App : Application
{
    public App()
    {
        SentrySdk.Init(options =>
        {
            // Tells which project in Sentry to send events to:
            options.Dsn = "___PUBLIC_DSN___";

            // When configuring for the first time, to see what the SDK is doing:
            options.Debug = true;

            // Adds request URL and headers, IP and name for users, etc.
            options.SendDefaultPii = true;

            // ___PRODUCT_OPTION_START___ performance
            // Set traces_sample_rate to 1.0 to capture 100% of transactions for tracing.
            // We recommend adjusting this value in production.
            options.TracesSampleRate = 1.0;

            // ___PRODUCT_OPTION_END___ performance
            // Enable Global Mode since this is a client app
            options.IsGlobalModeEnabled = true;

            //TODO: any other options you need go here
        });
        DispatcherUnhandledException += App_DispatcherUnhandledException;
    }

    void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
    {
        SentrySdk.CaptureException(e.Exception);

        // If you want to avoid the application from crashing:
        e.Handled = true;
    }
}
```

## [Verify](https://docs.sentry.io/platforms/dotnet/guides/wpf.md#verify)

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

```csharp
try
{
    throw null;
}
catch (Exception ex)
{
    SentrySdk.CaptureException(ex);
}
```

## [Next Steps](https://docs.sentry.io/platforms/dotnet/guides/wpf.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup

## Other .NET Frameworks

- [.NET for Android](https://docs.sentry.io/platforms/dotnet/guides/android.md)
- [.NET for iOS, macOS, and Mac Catalyst](https://docs.sentry.io/platforms/dotnet/guides/apple.md)
- [ASP.NET](https://docs.sentry.io/platforms/dotnet/guides/aspnet.md)
- [ASP.NET Core](https://docs.sentry.io/platforms/dotnet/guides/aspnetcore.md)
- [AWS Lambda](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md)
- [Azure Functions](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker.md)
- [Blazor Interactive SSR](https://docs.sentry.io/platforms/dotnet/guides/blazor-server.md)
- [Blazor WebAssembly](https://docs.sentry.io/platforms/dotnet/guides/blazor-webassembly.md)
- [Entity Framework](https://docs.sentry.io/platforms/dotnet/guides/entityframework.md)
- [Google Cloud Functions](https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions.md)
- [log4net](https://docs.sentry.io/platforms/dotnet/guides/log4net.md)
- [MAUI](https://docs.sentry.io/platforms/dotnet/guides/maui.md)
- [Microsoft.Extensions.Logging](https://docs.sentry.io/platforms/dotnet/guides/extensions-logging.md)
- [NLog](https://docs.sentry.io/platforms/dotnet/guides/nlog.md)
- [Serilog](https://docs.sentry.io/platforms/dotnet/guides/serilog.md)
- [Windows Forms](https://docs.sentry.io/platforms/dotnet/guides/winforms.md)
- [WinUI](https://docs.sentry.io/platforms/dotnet/guides/winui.md)
- [Xamarin](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md)

## Topics

- [Capturing Errors](https://docs.sentry.io/platforms/dotnet/guides/wpf/usage.md)
- [Enriching Events](https://docs.sentry.io/platforms/dotnet/guides/wpf/enriching-events.md)
- [Extended Configuration](https://docs.sentry.io/platforms/dotnet/guides/wpf/configuration.md)
- [Logs](https://docs.sentry.io/platforms/dotnet/guides/wpf/logs.md)
- [Data Management](https://docs.sentry.io/platforms/dotnet/guides/wpf/data-management.md)
- [Tracing](https://docs.sentry.io/platforms/dotnet/guides/wpf/tracing.md)
- [Profiling](https://docs.sentry.io/platforms/dotnet/guides/wpf/profiling.md)
- [Security Policy Reporting](https://docs.sentry.io/platforms/dotnet/guides/wpf/security-policy-reporting.md)
- [Crons](https://docs.sentry.io/platforms/dotnet/guides/wpf/crons.md)
- [Migration Guide](https://docs.sentry.io/platforms/dotnet/guides/wpf/migration.md)
- [Troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/wpf/troubleshooting.md)
- [User Feedback](https://docs.sentry.io/platforms/dotnet/guides/wpf/user-feedback.md)
- [Metrics](https://docs.sentry.io/platforms/dotnet/guides/wpf/metrics.md)
- [Unit Testing](https://docs.sentry.io/platforms/dotnet/guides/wpf/unit-testing.md)
- [Legacy SDK](https://docs.sentry.io/platforms/dotnet/guides/wpf/legacy-sdk.md)
