Other .NET apps

Add BugSnag to other .NET applications to automatically capture and report exceptions in production.

New to BugSnag? Create an account

Looking for performance monitoring? See our performance guide

Installation

  • Install the Bugsnag package from NuGet.

Manual installation

  • Download the latest DLLs.
  • Reference Bugsnag.dll in your project.

The latest available version of Bugsnag is v3.1.0.

Compatibility

  • .NET Framework 3.5, 4.0 and 4.5+
  • .NET Core 1.x, 2.x and 3.x
  • .NET 5+

For more information, see the Compatibility guide.

Basic configuration

Create a BugSnag client when your application starts.

var bugsnag = new Bugsnag.Client(new Configuration("your-api-key-goes-here"));

You can find your API key in Project Settings from your BugSnag dashboard.

Reporting unhandled exceptions

After completing installation and basic configuration, unhandled exceptions will be automatically reported to your BugSnag dashboard.

Reporting handled exceptions

If you would like to send non-fatal exception to BugSnag, you can pass any object that inherits from System.Exception to the Notify method

try
{
  throw new System.NotImplementedException();
}
catch (System.Exception ex)
{
  bugsnag.Notify(ex);
}

Sending diagnostic data

Customizing report severity

You can set the severity of an error in BugSnag by including the severity option when notifying BugSnag of the error

try
{
  throw new System.NotImplementedException();
}
catch (System.Exception ex)
{
  bugsnag.Notify(ex, Bugsnag.Severity.Info);
}

Logging breadcrumbs

In order to understand what happened in your application before each error, it can be helpful to leave short log statements that we call breadcrumbs. The last 25 breadcrumbs are attached to an error report to help diagnose what events lead to the error. Captured breadcrumbs are shown on your BugSnag dashboard as a part of the error report.

You can leave manual breadcrumbs via the Breadcrumbs property on the client object.

bugsnag.Breadcrumbs
  .Leave("Something happened!");

You can optionally attach a type and metadata to a breadcrumb for additional context into the state of the application when the breadcrumb was captured.

bugsnag.Breadcrumbs
  .Leave("Something happened!", Bugsnag.BreadcrumbType.Navigation, null);

With additional diagnostic metadata:

var metadata = new Dictionary<string, string> { { "foo", "bar" } }
bugsnag.Breadcrumbs
  .Leave("Something happened!", Bugsnag.BreadcrumbType.State, metadata);

Session tracking

Bugsnag can track the number of “sessions” that happen in your application. This enables BugSnag to provide and compare stability scores between releases to help you understand the quality of your releases.

You can manually create a new session when appropriate for your application:

bugsnag.SessionTracking.CreateSession();

Symbolication guide

Stacktraces from .NET platforms will be automatically populated with line numbers and file names for dlls that the runtime can find symbols for. This usually means that you should deploy the .pdb files alongside your dlls so that BugSnag is able to retrieve this information.

Next steps