Other .NET apps

Add Bugsnag to other .NET applications.

New to Bugsnag? Create an account and add Bugsnag to your app to automatically capture and report exceptions in production.

Installation

  • Install the Bugsnag package from NuGet.

Manual Library Reference

  • Download the latest dlls and reference Bugsnag.dll in your project.

Compatibility

  • .NET 3.5
  • .NET 4.0
  • .NET 4.5
  • Netstandard1.3
  • Netstandard2.0

more details

Basic configuration

  1. Create a Bugsnag client when your application starts.
var bugsnag = new Bugsnag.Client(new Configuration("your-api-key-goes-here"));

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