On this page, we get you up and running with Sentry's .NET SDK, automatically reporting errors and exceptions in your application.

If you don't already have an account and Sentry project established, head over to sentry.io, then return to this page.

Related Guides

This SDK is compatible with the latest .NET and .NET Core platforms, as well as .NET Standard 2.0 and .NET Framework 4.6.1 or newer. You can use it with applications written in C#, VB.NET, F#, and other .NET programming languages. For older versions, such as .NET Framework 3.5, you may continue to use our legacy SDK, until further notice.

Sentry captures data by using an SDK within your application’s runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works.

Install the NuGet package to add the Sentry dependency:

Sentry profiling for .NET is available in Alpha on .NET 6.0+ (tested on .NET 7.0 & .NET 8.0 as well).

dotnet add package Sentry.Profiling -v 4.7.0

To capture all errors, even the one during the startup of your application, you should initialize the Sentry .NET SDK as soon as possible.

SentrySdk.Init(options =>
    options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.us.sentry.io/5428537";
    options.Debug = true;
    options.AutoSessionTracking = true;
    // A fixed sample rate of 1.0 - 100% of all transactions are getting sent
    options.TracesSampleRate = 1.0f;
    // A sample rate for profiling - this is relative to TracesSampleRate
    options.ProfilesSampleRate = 1.0f;

The SDK will capture unhandled exceptions that are simply thrown or you can handle the error by calling CaptureException explicitely.

using Sentry;

    throw null;
catch (Exception ex)
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").