Troubleshooting

Sentry CLI not configured

The following message may appear in your build output:

The Sentry CLI is not fully configured with authentication, organization, and project.

The message currently appears as information only, though we may change it to a warning in the future. This means that you are building in Release configuration, and you have not fully configured MSBuild for Sentry CLI. You can handle this in one of the following ways:

  • You can enable the Sentry CLI in your build by providing configuration details, as described in the documentation here.

  • You can prevent the message from being generated by setting the property <UseSentryCLI>false</UseSentryCLI> in your .NET project file, or with /p:UseSentryCLI=false on the command line to dotnet build or msbuild. Sentry CLI will be disabled.

  • You can do nothing, and just ignore the message. Sentry CLI will be disabled.

Keep in mind that if the Sentry CLI is disabled, then debug information files such as PDB symbols will not be sent to Sentry. If Sentry cannot locate symbols, then it cannot perform symbolication of stack traces. This means that for some types of projects (depending on configuration), you may not see filenames and line numbers to help you locate the source of an exception.

The event is dropped by Sentry because it's too large

Sentry: (Error) Sentry rejected the envelope 5bfe4129cb2446c08768b16479865035. Status code: RequestEntityTooLarge. Error detail: failed to read request body. Error causes: A payload reached size limit..

You can have the Sentry .NET SDK write these envelopes to a path in order to troubleshoot why they are too large. Set the environment variable SENTRY_KEEP_LARGE_ENVELOPE_PATH to the directory you want these to be written to. Make sure the process the SDK is running in has write access to it.

User IP address in Sentry shows up as the server IP

If you're using a proxy server that relies on X-Forwarded-For, you might need to configure ASP.NET Core so that it's aware of it.

See this GitHub issue for more context.

Unhandled exceptions are not captured when using an async Main method

Starting with C# 7.1, a program's Main method can be declared either synchronously or asynchronously. However, the asynchronous approach is not fully compatible with the Sentry SDK. If your application uses an async Main method, the Sentry SDK will be disposed before an unhandled exception can be captured.

In other words, this is insufficient:

Copied
static async Task Main()
{
    using var _ = SentrySdk.Init(o => { /* your options */ });
    await DoSomethingAsync(); // an unhandled exception here will not be captured by Sentry
}

There are two different ways to work around this issue:

  • You can avoid unhandled exceptions by wrapping your code in a try/catch block:

    Copied
    static async Task Main()
    {
        using var _ = SentrySdk.Init(o => { /* your options */ });
        try
        {
            await DoSomethingAsync();
        }
        catch (Exception ex)
        {
            SentrySdk.CaptureException(ex);
        }
    }
  • You can use a synchronous Main method to ensure the Sentry SDK isn't disposed prematurely:

    Copied
    static void Main()
    {
        using var _ = SentrySdk.Init(o => { /* your options */ });
        MainAsync().GetAwaiter().GetResult();
    }
    
    static async Task MainAsync()
    {
        await DoSomethingAsync();
    }

    Note that with this approach, it is not advised to use .Wait() or .Result, as that would wrap unhandled exceptions in an AggregateException.

See this GitHub issue for more context.

Build Issues

Package Conflict - Conflict with Sentry.DiagnosticsSource

Copied
The call is ambiguous between the following methods or properties:
Sentry.SentryOptionsExtensions.DisableDiagnosticSourceIntegration(Sentry.SentryOptions)
and Sentry.SentryOptionsDiagnosticExtensions.DisableDiagnosticSourceIntegration(Sentry.SentryOptions)

The above error means that the version of the Sentry package you are using already contains the DiagnosticSource integration within itself, but you additionally installed Sentry.DiagnosticSource, which is only relevant for older framework versions.

To resolve this problem, remove the package reference to Sentry.DiagnosticSource.

Missing Definition

SentryOptions does not contain a definition for AddDiagnosticSourceIntegration.

The above error could have two meanings:

  • You're using an outdated SDK (3.8.3 or older).

  • Your project already includes the integration automatically. You can validate it by observing the debug information from Sentry SDK. Enable it through the options.

Your debug window will have following messages:

Copied
Debug: Logging enabled with ConsoleDiagnosticLogger and min level: Debug
Debug: Initializing Hub for Dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0'.
Debug: Using 'GzipBufferedRequestBodyHandler' body compression strategy with level Optimal.
Debug: New scope pushed.
Debug: Registering integration: 'AutoSessionTrackingIntegration'.
Debug: Registering integration: 'AppDomainUnhandledExceptionIntegration'.
Debug: Registering integration: 'AppDomainProcessExitIntegration'.
Debug: Registering integration: 'TaskUnobservedTaskExceptionIntegration'.
Debug: Registering integration: 'SentryDiagnosticListenerIntegration'.

If the debug file contains information about SentryDiagnosticListenerIntegration, then your project already includes the integration automatically.

Implicit Usings

From version 3.14.0, Sentry will respect Implicit Usings. This means is Implicit Usings is enabled (<ImplicitUsings>enable</ImplicitUsings> or <ImplicitUsings>true</ImplicitUsings>) then Sentry will be added to the current global using directives. This means that using Sentry; can be omitted from any .cs files.

In some scenarios Implicit Usings can result in type name conflicts. For example Session may exist in multiple namespaces. This can be resolved by fully qualifying the type inline (Sentry.Session), or with a using alias:

Copied
using SentrySession = Sentry.Session;

Then SentrySession can be used instead of SentrySession.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").