# Xamarin | Sentry for Xamarin

Sentry's .NET SDK works with Xamarin applications through the [Sentry Xamarin NuGet package](https://www.nuget.org/packages/Sentry.Xamarin) and Xamarin Forms with the [Sentry Xamarin Forms NuGet package](https://www.nuget.org/packages/Sentry.Xamarin.Forms).

The SDK is compatible with the following versions or higher:

* Xamarin.Android 9.0
* Xamarin.iOS 10.14
* Universal Windows Platform 10.0.16299
* Tizen 4.0

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

Install the **NuGet** package:

```shell
# For Xamarin.Forms
Install-Package Sentry.Xamarin.Forms -Version 2.1.0

# If you are not using Xamarin.Forms, but only Xamarin:
Install-Package Sentry.Xamarin -Version 2.1.0
```

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

After you’ve completed setting up a project in Sentry, Sentry will give you a value which we call a DSN or Data Source Name. It looks a lot like a standard URL, but it’s just a representation of the configuration required by the Sentry SDKs. It consists of a few pieces, including the protocol, public key, the server address, and the project identifier.

Error Monitoring\[ ]Tracing

You should initialize the SDK as early as possible, for an example, the start of OnCreate on MainActivity for Android, and, the top of FinishedLaunching on AppDelegate for iOS).

```csharp
SentryXamarin.Init(options =>
{
    options.AddXamarinFormsIntegration();
    // Tells which project in Sentry to send events to:
    options.Dsn = "___PUBLIC_DSN___";
    // When configuring for the first time, to see what the SDK is doing:
    options.Debug = true;
    // Adds request URL and headers, IP and name for users, etc.
    options.SendDefaultPii = true;
    // ___PRODUCT_OPTION_START___ performance
    // Set TracesSampleRate to 1.0 to capture 100%
    // of transactions for tracing.
    // We recommend adjusting this value in production
    options.TracesSampleRate = 1.0;
    // ___PRODUCT_OPTION_END___ performance
});
// App code
```

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

Great! Now that you’ve completed setting up the SDK, maybe you want to quickly test out how Sentry works. Start by capturing an exception:

You can verify Sentry is capturing unhandled exceptions by raising an exception. For example, you can use the following snippet to raise a `NullReferenceException`:

```csharp
throw null;
```

All you need to do is to [initialize the SDK with `SentryXamarin.Init`](https://docs.sentry.io/platforms/dotnet.md), you will not need any additional changes to get the SDK ready to go.

The SDK automatically handles `AppDomain.UnhandledException` and `Application.UnhandledException`, so you'll not need to worry about trying to Catch Unhandled Exceptions.

### [Xamarin Options](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#xamarin-options)

The following options are only going to be valid during the SDK initialization.

#### [DisableNativeIntegration](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#disablenativeintegration)

Disable the native event processor for Android,iOS,UWP

#### [DisableOfflineCaching](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#disableofflinecaching)

By calling it, the SDK will not automatically Cache your events and they might be lost if a hard crash happens or no connectivity is available during the transport of the event.

#### [AttachScreenshots](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#attachscreenshots)

Automatically attaches a screenshot of the app at the time of the event capture. By default, it is set to false.

##### Note

Note that personally identifiable information (PII) might be included in the screenshot when you activate this feature.

### [Xamarin Forms Options](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#xamarin-forms-options)

#### [DisableXamarinWarningsBreadcrumbs](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#disablexamarinwarningsbreadcrumbs)

Disables the automatic Logging of internal Warnings that comes from Xamarin Forms.

## [Troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#troubleshooting)

For information about Troubleshooting, please visit the [troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/xamarin/troubleshooting.md) page.

## [Samples](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md#samples)

* An [example](https://github.com/getsentry/sentry-xamarin/tree/main/Samples) using Xamarin Forms and most of the SDK features. (**Android, iOS, UWP**)

## Pages in this section

- [configuration](https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration.md)
- [crons](https://docs.sentry.io/platforms/dotnet/guides/xamarin/crons.md)
- [data-management](https://docs.sentry.io/platforms/dotnet/guides/xamarin/data-management.md)
- [enriching-events](https://docs.sentry.io/platforms/dotnet/guides/xamarin/enriching-events.md)
- [ignoring-exceptions](https://docs.sentry.io/platforms/dotnet/guides/xamarin/ignoring-exceptions.md)
- [legacy-sdk](https://docs.sentry.io/platforms/dotnet/guides/xamarin/legacy-sdk.md)
- [migration](https://docs.sentry.io/platforms/dotnet/guides/xamarin/migration.md)
- [profiling](https://docs.sentry.io/platforms/dotnet/guides/xamarin/profiling.md)
- [security-policy-reporting](https://docs.sentry.io/platforms/dotnet/guides/xamarin/security-policy-reporting.md)
- [tracing](https://docs.sentry.io/platforms/dotnet/guides/xamarin/tracing.md)
- [troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/xamarin/troubleshooting.md)
- [unit-testing](https://docs.sentry.io/platforms/dotnet/guides/xamarin/unit-testing.md)
- [usage](https://docs.sentry.io/platforms/dotnet/guides/xamarin/usage.md)
- [user-feedback](https://docs.sentry.io/platforms/dotnet/guides/xamarin/user-feedback.md)
