The Raygun4Net Provider

Whether you're maintaining classic desktop software, crafting an ASP.NET web application or on on the cutting edge of Windows 8 development, supports it. The lightweight and speedy Raygun4Net provider allows you to catch and send exceptions from your .NET application or Windows Store app. It takes just 5 minutes of setup to plug Raygun4Net into your code-base - errors will then appear immediately on your dashboard.

Supports the whole framework

Raygun4Net can be dropped in to applications that use the following .NET libraries:

  • WinForms
  • WPF
  • WCF
  • WF
  • Base Class Library
  • WinRT
  • Windows Phone 7.1 and 8
  • Windows Store (Universal apps) Windows 8.1 and Windows Phone 8.1
  • Xamarin for iOS, Android and Mac

Raygun4Net supports .NET 2.0 and greater.


Track exceptions from your Windows Store apps with ease. Raygun4Net comes with three assemblies - one being specifically built for WinRT. Add this to your project and errors will be transmitted immediately, just like in .NET. The error-sending API is identical for both, providing a low-impact way to display exceptions from your WinRT apps in

Windows Phone

Don't be left in the dark about your Windows Phone applications. One of the assemblies supplied with this provider has full support for both Windows Phone 7.1 and 8.0. The API and setup process is almost identical to the main .Net Raygun assembly. The Windows Phone assembly even has special support for when errors occur when the device is not connected to the internet. Messages are stored in isolated storage until they can be sent.

Xamarin Android and Xamarin iOS

Raygun also has first-class support for these two Xamarin mobile platforms. They're just as easy to use and same as Windows Phone will cache errors when the network is not available on the device. The component can be installed from the Xamarin component store.

Getting Raygun4Net

This procedure is valid for both .NET and WinRT projects. For Visual Studio 2010 and 2012, Raygun4Net is available from NuGet.

  1. Install the NuGet Package Manager Visual Studio extension if it is not currently installed
  2. In the Solution Explorer, right-click your project and select 'Manage NuGet Packages'
  3. Go to Online -> All, search for 'Raygun4Net', then click Install on Mindscape.Raygun4Net

For Visual Studio 2008, or if you don't want to use NuGet, you can also clone the GitHub repository linked below. After getting the code, run build.bat, then add the correct assembly, located in /release.

Setting up Raygun4Net


Inside configSections, add the following entry, then reference it:

<section name="RaygunSettings" type="Mindscape.Raygun4Net.RaygunSettings, Mindscape.Raygun4Net"/>

<RaygunSettings apikey="YOUR_APP_API_KEY" />

You can then either create a new instance of the RaygunClient class and call Send(Exception):

protected void Application_Error()
  var exception = Server.GetLastError();
  new RaygunClient().Send(exception);

Or there is an HttpModule you can add.

For system.web:

  <add name="RaygunErrorModule" type="Mindscape.Raygun4Net.RaygunHttpModule"/>

For system.webServer:

  <add name="RaygunErrorModule" type="Mindscape.Raygun4Net.RaygunHttpModule"/>

WinForms/WPF/Other .NET Applications

Create an instance of RaygunClient then inside an Unhandled Exception (or unobserved task exception) event handler make a call to Send, passing the ExceptionObject available in the handler's EventArgs. The main difference from ASP.NET applications is that you pass in your API key in the constructor call to RaygunClient. Read below for code examples for the different frameworks:


Create an instance of RaygunClient by passing your app API key in the constructor. Attach an event handler to the DispatcherUnhandledException event of your application. In the event handler, use the RaygunClient.Send method to send the Exception.

private RaygunClient _client = new RaygunClient("YOUR_APP_API_KEY");

public App()
  DispatcherUnhandledException += OnDispatcherUnhandledException;

void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)


Create an instance of RaygunClient by passing your app API key in the constructor. Attach an event handler to the Application.ThreadException event BEFORE calling Application.Run(...). In the event handler, use the RaygunClient.Send method to send the Exception.

private static readonly RaygunClient _raygunClient = new RaygunClient("YOUR_APP_API_KEY");

static void Main()

  Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
  AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Application.Run(new Form1());

private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  _raygunClient.Send(e.ExceptionObject as Exception);

Windows Phone 7.1 and 8

private RaygunClient _client = new RaygunClient("YOUR_APP_API_KEY");

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

Xamarin for Android

In the main/entry Activity of your application, use the static RaygunClient.Attach method using your app API key. There is also an overload for the Attach method that lets you pass in a user-identity string which is useful for tracking affected users in your dashboard.


At any point after calling the Attach method, you can use RaygunClient.SharedClient to get the static instance. This can be used for manually sending messages or changing options such as the User identity string.

Xamarin for iOS

The above instructions for Android also apply for iOS:

static void Main(string[] args)

  UIApplication.Main(args, null, "AppDelegate");

Xamarin for Mac

Xamarin for Mac support is not included in the NuGet package or the Raygun4Net Xamarin Component. Instead, download the .zip of assemblies from the latest release on GitHub (Click the green button). Then copy and reference the Mindscape.Raygun4Net.Xamarin.Mac.dll into your Xamarin.Mac project.

In the main entry point of your application, call the static RaygunClient.Attach method using your app API key.

static void Main(string[] args)



public App()
  UnhandledException += App_UnhandledException;

void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)


To view the documentation for .NET, including user tracking, custom data, tags and filtering sensitive request data, view the .NET documentation here.

Source code

For complete installation instructions, access to the source code and troubleshooting, visit the GitHub repository here.