$npx -y skills add getsentry/sentry-for-ai --skill sentry-dotnet-sdkFull 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.
| 1 | > [All Skills](../../SKILL_TREE.md) > [SDK Setup](../sentry-sdk-setup/SKILL.md) > .NET SDK |
| 2 | |
| 3 | # Sentry .NET SDK |
| 4 | |
| 5 | Opinionated wizard that scans your .NET project and guides you through complete Sentry setup: error monitoring, distributed tracing, profiling, structured logging, and cron monitoring across all major .NET frameworks. |
| 6 | |
| 7 | ## Invoke This Skill When |
| 8 | |
| 9 | - User asks to "add Sentry to .NET", "set up Sentry in C#", or "install Sentry for ASP.NET Core" |
| 10 | - User wants error monitoring, tracing, profiling, logging, or crons for a .NET app |
| 11 | - User mentions `SentrySdk.Init`, `UseSentry`, `Sentry.AspNetCore`, or `Sentry.Maui` |
| 12 | - User wants to capture unhandled exceptions in WPF, WinForms, MAUI, or Azure Functions |
| 13 | - User asks about `SentryOptions`, `BeforeSend`, `TracesSampleRate`, or symbol upload |
| 14 | |
| 15 | > **Note:** SDK version and APIs below reflect `Sentry` NuGet packages ≥6.1.0 (OTLP export requires ≥6.5.0). |
| 16 | > Always verify against [docs.sentry.io/platforms/dotnet/](https://docs.sentry.io/platforms/dotnet/) before implementing. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Phase 1: Detect |
| 21 | |
| 22 | Run these commands to understand the project before making any recommendations: |
| 23 | |
| 24 | ```bash |
| 25 | # Detect framework type — find all .csproj files |
| 26 | find . -name "*.csproj" | head -20 |
| 27 | |
| 28 | # Detect framework targets |
| 29 | grep -r "TargetFramework\|Project Sdk" --include="*.csproj" . |
| 30 | |
| 31 | # Check for existing Sentry packages |
| 32 | grep -r "Sentry" --include="*.csproj" . | grep "PackageReference" |
| 33 | |
| 34 | # Check startup files |
| 35 | ls Program.cs src/Program.cs App.xaml.cs MauiProgram.cs 2>/dev/null |
| 36 | |
| 37 | # Check for appsettings |
| 38 | ls appsettings.json src/appsettings.json 2>/dev/null |
| 39 | |
| 40 | # Check for logging libraries |
| 41 | grep -r "Serilog\|NLog\|log4net" --include="*.csproj" . |
| 42 | |
| 43 | # Check for companion frontend |
| 44 | ls ../frontend ../client ../web 2>/dev/null |
| 45 | cat ../package.json 2>/dev/null | grep -E '"next"|"react"|"vue"' | head -3 |
| 46 | ``` |
| 47 | |
| 48 | **What to determine:** |
| 49 | |
| 50 | | Question | Impact | |
| 51 | |----------|--------| |
| 52 | | Framework type? | Determines correct package and init pattern | |
| 53 | | .NET version? | .NET 8+ recommended; .NET Framework 4.6.2+ supported | |
| 54 | | Sentry already installed? | Skip install, go to feature config | |
| 55 | | Logging library (Serilog, NLog)? | Recommend matching Sentry sink/target | |
| 56 | | Async/hosted app (ASP.NET Core)? | `UseSentry()` on `WebHost`; no `IsGlobalModeEnabled` needed | |
| 57 | | Desktop app (WPF, WinForms, WinUI)? | Must set `IsGlobalModeEnabled = true` | |
| 58 | | Serverless (Azure Functions, Lambda)? | Must set `FlushOnCompletedRequest = true` | |
| 59 | | Frontend directory found? | Trigger Phase 4 cross-link | |
| 60 | |
| 61 | **Framework → Package mapping:** |
| 62 | |
| 63 | | Detected | Package to install | |
| 64 | |----------|--------------------| |
| 65 | | `Sdk="Microsoft.NET.Sdk.Web"` (ASP.NET Core) | `Sentry.AspNetCore` | |
| 66 | | `App.xaml.cs` with `Application` base | `Sentry` (WPF) | |
| 67 | | `[STAThread]` in `Program.cs` | `Sentry` (WinForms) | |
| 68 | | `MauiProgram.cs` | `Sentry.Maui` | |
| 69 | | `WebAssemblyHostBuilder` | `Sentry.AspNetCore.Blazor.WebAssembly` | |
| 70 | | `FunctionsStartup` | `Sentry.Extensions.Logging` + `Sentry.OpenTelemetry` | |
| 71 | | `HttpApplication` / `Global.asax` | `Sentry.AspNet` | |
| 72 | | Generic host / Worker Service | `Sentry.Extensions.Logging` | |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ## Phase 2: Recommend |
| 77 | |
| 78 | Present a concrete recommendation based on what you found. Lead with a proposal — don't ask open-ended questions. |
| 79 | |
| 80 | **Recommended (core coverage):** |
| 81 | - ✅ **Error Monitoring** — always; captures unhandled exceptions, structured captures, scope enrichment |
| 82 | - ✅ **Tracing** — always for ASP.NET Core and hosted apps; auto-instruments HTTP requests and EF Core queries |
| 83 | - ✅ **Logging** — recommended for all apps; routes ILogger / Serilog / NLog entries to Sentry as breadcrumbs and events |
| 84 | |
| 85 | **Optional (enhanced observability):** |
| 86 | - ⚡ **Profiling** — CPU profiling; recommend for performance-critical services running on .NET 6+ |
| 87 | - ⚡ **Metrics** — counters, gauges, distributions linked to traces; recommend for apps that need custom business metrics |
| 88 | - ⚡ **Crons** — detect missed/failed scheduled jobs; recommend when Hangfire, Quartz.NET, or scheduled endpoints detected |
| 89 | |
| 90 | **Recommendation logic:** |
| 91 | |
| 92 | | Feature | Recommend when... | |
| 93 | |---------|------------------| |
| 94 | | Error Monitoring | **Always** — non-negotiable baseline | |
| 95 | | Tracing | **Always for ASP.NET Core** — request traces, EF Core spans, HttpClient spans are high-value | |
| 96 | | Logging | App uses `ILogger<T>`, Serilog, NLog, or log4net | |
| 97 | | Profiling | Performance-critical service on .NET 6+ | |
| 98 | | Metrics | App needs custom business metrics (request counts, queue depths, response times) | |
| 99 | | Crons | App uses Hangfire, Quartz.NET, or scheduled Azure Functions | |
| 100 | |
| 101 | Propose: *"I recommend setting up Error Monitoring + Trac |