Raygun4Maui will get you set up with Raygun Crash Reporting for your .NET MAUI application in no time.

The best way to install Raygun is to use the NuGet package manager. Right-click on your project and select "Manage NuGet Packages....". Navigate to the Browse tab, then use the search box to find Raygun4Maui and install it.

To install the latest version:

dotnet add package Raygun4Maui

Alternatively, you can specify a version tag to install a specific version of the package. See Raygun4Maui NuGet Gallery page for information on available versions.

dotnet add package Raygun4Maui --version 1.2.2

Import the module by:

using Raygun4Maui;

To activate sending of unhandled exceptions and logs to Raygun, you must add Raygun4Maui to your MauiApp builder. To do so, open your main MauiProgram class (MauiProgram.cs) and change the CreateMauiApp method by adding the AddRaygun4Maui extension method:

var builder = MauiApp.CreateBuilder();

Deploy Raygun into your production environment for best results, or raise a test exception. Once we detect your first error event, the Raygun app will automatically update.

The AddRaygun4Maui extension method contains an overloaded method that takes a RaygunMauiSettings options object. This extends RaygunSettings from Raygun4Net.

RaygunMauiSettings supports the following configurations:

  • Any configuration available in the Raygun4Net RaygunSettings, such as ApiKey.
  • SendDefaultTags (defaulted to true) adds the Log Level (e.g., Severe, Warning, etc.) and the Build Platform (e.g., Windows, Android, iOS, etc.) to reports and logs sent to Raygun.
  • SendDefaultCustomData (defaulted to true) adds all available information in the uncaught exception as custom data on the crash report sent to Raygun.
  • MinLogLevel and MaxLogLevel that specify the range of logging levels to be sent to Raygun.

To use these additional configurations, create and initialize a new RaygunMauiSettings object as follows:

Raygun4MauiSettings raygunMauiSettings = new Raygun4MauiSettings {
    ApiKey = "paste_your_api_key_here",
    SendDefaultTags = true, // defaults to true
    SendDefaultCustomData = true, // defaults to true
    MinLogLevel = LogLevel.Debug, // defaults to true
    MaxLogLevel = LogLevel.Critical // defaults to true

Then add Raygun4Maui to your MauiApp builder. This time, passing in the RaygunMauiSettings object instead of the API key directly:


Unhandled exceptions will be sent to Raygun automatically.

Raygun4Maui stores an instance of a RaygunMauiClient object that is initialized by the Maui builder, this can be accessed through the following code:


This client extends the Raygun4Net.NetCore RaygunClient, as a result any features supported by the Raygun4Net.NetCore Client are supported here.

Raygun4Maui automatically sends unhandled exceptions. For manual sending, use Send or SendInBackground methods, as shown below:

try {
    // Code that may fail
} catch (Exception e) {

An exception needs to be thrown in order for its stack trace to be populated. If the exception is created manually no stack trace data is collected.

For additional examples on how to use the RaygunMauiClient object refer to the Raygun4Net.NetCore documentation

Raygun4Maui will automatically send any logger logs to Raygun.

To make a log entry, obtain the reference to the ILogger services that your MAUI app maintains:

ILogger logger = Handler.MauiContext.Services.GetService<ILogger<MainPage>>();

You may now use the appropriate ILogger log method from the logger object. This uses the same RaygunMauiClient object accessible from RaygunMauiClient.Current

logger.LogInformation("Raygun4Maui.SampleApp.TestLoggerErrorsSent: {MethodName} @ {Timestamp}", "TestLogInformation", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
logger.LogCritical("Raygun4Maui.SampleApp.TestLoggerErrorsSent: {MethodName} @ {Timestamp}", "TestLogCritical", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));

This functionality also allows you to manually catch and log exceptions as shown below:

try {
    // Code that throws exception
} catch (Exception e) {
    // Example ILogger call. You can use the ILogger method and arguments of your choice.
    logger.Log(LogLevel.Error, e, "Exception caught at {Timestamp}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));

Raygun4Maui will automatically collect information specific to the environment the application is being run in. However, there are inconsistencies between certain values across platforms.

  • On iOS, Raygun4Maui cannot obtain the device's name. This is a privacy restriction put in place by Apple. If you would like this information to be collected and sent with crash reports you will have to request for permission from apple.
  • The Total physical memory and Available physical memory properties mean different things across platforms. Below is a table explaining the differences for each platform.
Platform Total physical memory Available physical memory
Mac Total installed ram Total memory available for user-level processes
iOS Total installed ram Total memory available for user-level processes
Windows Total installed ram Total amount of private memory used by the process at the time of the measurement. For a number of reasons this might not be the actual total memory usage
Android Total amount of memory that the JVM has allocated for the application Total amount of free memory that the JVM has available for the application to use

The provider is open source and available at the Raygun4Maui repository.