# .NET | Sentry for .NET

If you don't already have an account and Sentry project established, head over to [sentry.io](https://sentry.io/signup/), then return to this page.

You can use these instructions to run Sentry in an app running on:

* Windows
* macOS
* Linux
* Android
* iOS

If you're using a framework, such as ASP.NET Core or MAUI, please select the framework on the drop down on the top left.

## [Features](https://docs.sentry.io/platforms/dotnet.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/explore/profiling.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

## [Install](https://docs.sentry.io/platforms/dotnet.md#install)

Error Monitoring\[ ]Tracing\[ ]Profiling

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:

```shell
dotnet add package Sentry -v 6.0.0
```

```shell
dotnet add package Sentry.Profiling -v 6.0.0
```

## [Configure](https://docs.sentry.io/platforms/dotnet.md#configure)

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

```csharp
SentrySdk.Init(options =>
{
    options.Dsn = "___PUBLIC_DSN___";
    options.Debug = true;
    // Adds request URL and headers, IP and name for users, etc.
    options.SendDefaultPii = true;
    // ___PRODUCT_OPTION_START___ performance
    // A fixed sample rate of 1.0 - 100% of all transactions are getting sent
    options.TracesSampleRate = 1.0f;
    // ___PRODUCT_OPTION_END___ performance
    // ___PRODUCT_OPTION_START___ profiling
    // A sample rate for profiling - this is relative to TracesSampleRate
    options.ProfilesSampleRate = 1.0f;
    // ___PRODUCT_OPTION_END___ profiling
});
```

## [Verify](https://docs.sentry.io/platforms/dotnet.md#verify)

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

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