How Do You Create A Global Error Handling for a MAUI App

Viewed 721

Is there a way to set up a global error handler for a MAUI app? My app is currently running fine when I launch it from Visual Studio. However on all simulators if I try and start the app up from the shell's app icon, it starts up then quits (and on iOS I get a crash dump). I have no idea where this is happening at, so wanted to try and catch in a global handler.

I looked at builder.ConfigureMauiHandlers, but it appears to only work with controls. You can't use a type of UnhandledExceptionEventHandler, which is what I was thinking would be appropriate.

I also tried an AppDomain handler, but it doesn't not appear to work either:

AppDomain ad = AppDomain.CurrentDomain;
ad.UnhandledException += Ad_UnhandledException;

Is this possible? I've only found samples for WCF and they don't work.

1 Answers

Struggled with this for a while myself and ended up using Sentry.io, highly impressed so far!

Related