.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:
- Multiple integrations with additional features such as SQL Client, Serilog, log4net, ASP.NET Core, EntityFramework, EntityFramework Core, Xamarin
- Breadcrumbs automatically captured
- Release Health tracks crash free users and sessions
- Attachments enrich your event by storing additional files, such as config or log files
- User Feedback provides the ability to collect user information when an event occurs
- Performance Monitoring creates transactions to track the performance of your application
- Automatically captures errors including: unhandled exceptions and unobserved task exceptions
- Events enriched with device data
- Offline caching of events when a device is unable to connect
- Samples provided for multiple C# app models, F# Console, and Giraffe
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.
Using a framework?
Get started using a guide listed in the right sidebar.
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:
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
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:
using Sentry;
try
{
throw null;
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
}
Learn more about manually capturing an error or message in our Usage documentation.
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.
- Package:
- nuget:Sentry
- Version:
- 4.9.0
- Repository:
- https://github.com/getsentry/sentry-dotnet