dotnet add package Raygun4Maui
using Raygun4Maui;
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
...
.AddRaygun();
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
...
.AddRaygun(options => {
options.RaygunSettings.ApiKey = "PlhuoFGvMtGkI87xxnDA";
options.RaygunSettings.CatchUnhandledExceptions = true;
})
using Microsoft.Extensions.Logging;
using Raygun4Maui;
namespace Mapp
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.AddRaygun(options =>
{
options.RaygunSettings.ApiKey = "PlhuoFGvMtGkI87xxnDA";
options.RaygunSettings.CatchUnhandledExceptions = true;
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}
namespace Mapp
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
if (count == 2)
{
throw new Exception("exception");
}
}
}
}
namespace Mapp
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
// Triggering an unhandled exception (ArrayIndexOutOfRangeException)
int[] numbers = new int[3];
Console.WriteLine(numbers[5]); // This will throw an IndexOutOfRangeException
// Update the button text (this won't be reached)
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
// This line will never be reached because of the exception above
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
}