Search code examples
c#xamarinuwpvisual-studio-app-center

How do you register an event handler for TrackError in AppCenter SDK for C#?


I register event handlers before calling TrackError but they are never called. Yes, the events transpired because the errors showed up in AppCenter.

//On loading app
Crashes.SentErrorReport += (sender, args) => { System.Diagnostics.Process.GetCurrentProcess().Kill(); };
Crashes.FailedToSendErrorReport += (sender, args) => { System.Diagnostics.Process.GetCurrentProcess().Kill(); };

AppCenter.Start("{App secret here}" +
       "android={App secret here}" +
       "ios={App secret here}",
       typeof(Analytics), typeof(Crashes));

//Elsewhere in the app
Crashes.TrackError(exception, comments, attachments);

Following this documentation: https://learn.microsoft.com/en-us/appcenter/sdk/crashes/xamarin


Solution

  • This feature is not supported for handled exceptions aka errors in App Center (the ones reported by developer using Crashes.trackError manually).

    The events are triggered only for crashes (the unhandled exceptions causing the application to exit). Also those events are called after restart of the crashed process.