Back to Skills

sentry-dotnet-sdk

Full Sentry SDK setup for .NET. Use when asked to "add Sentry to .NET", "install Sentry for C#", or configure error monitoring, tracing, profiling, logging, or crons for ASP.NET Core, MAUI, WPF, WinForms, Blazor, Azure Functions, or any other .NET application.

237stars30forksUpdated 7/11/2026

Security Assessment

Low Risk(85/100)

Detected risks:

Agent-reviewed override(Substring false positive: 'RunAs' matched '.RunAsync()' (.NET Host.RunAsync, WaitUntilNextRunAsync); crontab is Sentry's cron-monitoring feature; .Env is SDK config. Legitimate Sentry .NET SDK skill.)
Security Score85/100

About sentry-dotnet-sdk

An opinionated setup wizard for adding the Sentry SDK to .NET applications, covering error monitoring, distributed tracing, profiling, structured logging, and cron monitoring across ASP.NET Core, MAUI, WPF, WinForms, Blazor WebAssembly, Azure Functions, classic ASP.NET, and generic host or worker services. It runs in three phases. Phase 1 Detect scans the project — locating .csproj files, target frameworks, existing Sentry packages, startup files (Program.cs, App.xaml.cs, MauiProgram.cs), appsettings.json, and logging libraries (Serilog, NLog, log4net) — and maps the detected framework to the correct package, for example Sentry.AspNetCore for web projects, Sentry for WPF/WinForms, Sentry.Maui for MAUI, and Sentry.AspNetCore.Blazor.WebAssembly for Blazor. Phase 2 Recommend proposes a concrete feature set, treating error monitoring as the non-negotiable baseline, tracing as default for ASP.NET Core (auto-instrumenting HTTP requests and EF Core queries), and logging when an ILogger, Serilog, NLog, or log4net is present, with profiling, metrics, and crons as optional enhancements based on what is detected (for example Hangfire or Quartz.NET for crons). Phase 3 Guide offers two paths: the recommended interactive wizard (npx @sentry/wizard@latest -i dotnet), which the user runs because it opens a browser and configures the DSN and MSBuild symbol upload, or a manual setup that installs the right package and wires initialization. Manual examples show ASP.NET Core using builder.WebHost.UseSentry with options like Dsn, TracesSampleRate, SendDefaultPii, event levels, and a BeforeSend hook to scrub data, plus equivalent appsettings.json and double-underscore environment-variable configuration. It notes framework-specific requirements — desktop apps must set IsGlobalModeEnabled, serverless must set FlushOnCompletedRequest, and WPF should initialize in the App constructor rather than OnStartup. APIs reflect Sentry NuGet packages 6.1.0 and newer (OTLP export requires 6.5.0), with a reminder to verify against the official docs.

FAQ

Which Sentry package should I install for my app?

It depends on the framework — Sentry.AspNetCore for ASP.NET Core, Sentry for WPF/WinForms/console, Sentry.Maui for MAUI, Sentry.AspNetCore.Blazor.WebAssembly for Blazor, and Sentry.Extensions.Logging with Sentry.OpenTelemetry for Azure Functions.

Should I use the wizard or set it up manually?

The wizard (npx @sentry/wizard@latest -i dotnet) is recommended and handles login, DSN, and symbol upload, but you run it yourself because it opens a browser; otherwise follow the manual dotnet add package path.

What special settings do desktop and serverless apps need?

Desktop apps (WPF, WinForms, WinUI) must set IsGlobalModeEnabled = true, and serverless apps such as Azure Functions or Lambda must set FlushOnCompletedRequest = true.

Where should I initialize Sentry in a WPF app?

In the App constructor, not in OnStartup(), because the constructor fires earlier and catches more failure modes.

What SDK version do these instructions target?

Sentry NuGet packages 6.1.0 and newer, with OTLP export requiring 6.5.0 or later; always verify against the official Sentry .NET docs before implementing.

All Files

7 files
SKILL.md22.8 KB
View
references/error-monitoring.md31.3 KB
View
references/tracing.md29.3 KB
View
references/logging.md16.9 KB
View
references/metrics.md6.9 KB
View
references/crons.md13.1 KB
View
references/profiling.md11.0 KB
View

Install sentry-dotnet-sdk

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill