.NET

Our .NET SDK supports all recent versions of the platform, and integrates well with a variety of popular frameworks and packages in the ecosystem. It gives developers helpful hints for where and why an error or performance issue might have occurred.

This SDK is compatible with .NET Standard 2.0 and .NET Framework 4.6.1. For older versions, such as .NET Framework 3.5, please refer to our legacy SDK.

Features:

On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your application.

Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.

Install

Sentry captures data by using an SDK within your application’s runtime.

Install the NuGet package to add the Sentry dependency:

Copied
dotnet add package Sentry -v 4.9.0

Configure

Configuration should happen as early as possible in your application's lifecycle.

For example, initialize in the Main method in Program.cs:

Program.cs
Copied
using (SentrySdk.Init(o => 
{
    // Tells which project in Sentry to send events to:
    o.Dsn = "https://examplePublicKey@o0.ingest.sentry.io/0";
    // When configuring for the first time, to see what the SDK is doing:
    o.Debug = true;
    // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
    // We recommend adjusting this value in production.
    o.TracesSampleRate = 1.0; 
}))
{
    // App code goes here - Disposing will flush events out
}

Verify

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

Copied
using Sentry;

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

To view and resolve the recorded error, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.