Dynatrace provides comprehensive error and crash reporting for .NET MAUI applications. The native OneAgent automatically captures unhandled exceptions and platform-level crashes on both Android and iOS platforms.
When you configure the Dynatrace MAUI plugin, automatic crash reporting is turned on by default. The native OneAgents capture crashes from the underlying Android and iOS platforms.
The native OneAgents automatically capture:
Automatic crash reporting is turned on by default. If you prefer to turn it off, you can configure it in the dynatrace.config.json file.
Android:
{"android": {"crashReporting": false}}
iOS:
{"ios": {"DTXCrashReportingEnabled": false}}
Application Not Responding (ANR) errors occur when the main thread is blocked for too long. Dynatrace automatically captures ANR events.
ANR events indicate that your app's UI became unresponsive.
ANR reporting is turned on by default. To turn it off in your dynatrace.config.json file:
Android:
{"android": {"anrReporting": false}}
iOS:
{"ios": {"DTXANRReportingEnabled": false}}
ANR events are only sent if the user restarts the app within 10 minutes of the ANR occurring. On Android, ANR reporting requires Android 11 or higher.
Use SendExceptionEvent() to report exceptions with full context and custom properties. The exception object is required; all other fields are optional.
using Dynatrace.MAUI;try{// Your code that might throw an exceptionPerformRiskyOperation();}catch (Exception exception){var exceptionEventData = new ExceptionEventData(exception);Agent.Instance.SendExceptionEvent(exceptionEventData);}
You can add context to exception events to help with debugging:
using Dynatrace.MAUI;try{await FetchUserData(userId);}catch (Exception exception){var exceptionEventData = new ExceptionEventData(exception).AddEventProperty("event_properties.operation", "fetch_user_data").AddEventProperty("event_properties.user_id_hash", userId.GetHashCode()).AddEventProperty("event_properties.retry_count", retryCount);Agent.Instance.SendExceptionEvent(exceptionEventData);}
You can use the IAction.ReportError API to manually report errors in your application. This allows you to capture and send custom error information to Dynatrace.
using Dynatrace.MAUI;try{// Your code that might throw an exceptionPerformRiskyOperation();}catch (Exception ex){// Report the error to DynatraceIRootAction action = Agent.Instance.EnterAction("ParentAction");action.ReportError("Custom error occurred", -1);action.LeaveAction();}
The ReportError API forwards data to Grail. The Android and iOS agents generate RUM on Grail data from this API, which means the error data will not pass through the event modifier in the MAUI scope.