I'm implementing Visual Studio AppCenter for handling crashes, as it's replacing HockeyApp. I'm testing it out by throwing an exception manually in my code (NOT within a try/catch block):
throw new Exception ("New exception when redirecting to property details!");
I then have code that globally handles any uncaught exceptions in Application.cs and tries to log them to AppCenter with the Crashes.TrackError call:
AndroidEnvironment.UnhandledExceptionRaiser += LogException;
private void LogException (object sender, RaiseThrowableEventArgs e) {
var exc = e.Exception;
if (ShouldLogException (exc)) {
// Log exception to AppCenter.
var properties = AppCenterLoggingSink.GetProperties ();
Crashes.TrackError (exc, properties);
e.Handled = true;
}
}
When I do this, the stack trace that it logs to the console looks good:
[MonoDroid] System.Exception: New exception when redirecting to property details! [MonoDroid] at RPR.Mobile.Droid.Fragments.RecentActivityFragment.RedirectToPropertyDetails (RPR.Mobile.Shared.Entities.PropertyDetails.Property property) [0x00001] in /Users/justintoth/Documents/rpr-mobile/android-application/Fragments/RecentActivityFragment.cs:190 [MonoDroid] at RPR.Mobile.Droid.Fragments.RecentActivityFragment.b__15_0 (RPR.Mobile.Shared.Entities.PropertyDetails.Property property) [0x00000] in /Users/justintoth/Documents/rpr-mobile/android-application/Fragments/RecentActivityFragment.cs:170 [MonoDroid] at RPR.Mobile.Droid.Adapters.SearchResults.PropertyListRowPhotoAdapter.b__2_0 (System.Object o, System.EventArgs e) [0x00001] in /Users/justintoth/Documents/rpr-mobile/android-application/Adapters/SearchResults/PropertyListRowPhotoAdapter.cs:34 [MonoDroid] at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00011] in <5f142c269d8a438c94480ac03744dec7>:0 [MonoDroid] at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in <5f142c269d8a438c94480ac03744dec7>:0 [MonoDroid] at (wrapper dynamic-method) System.Object.60(intptr,intptr,intptr)
However, as the app closes it logs the exception to the console with a bad stack trace:
[AppCenterCrashes] System.Exception: New exception when redirecting to property details! [AppCenterCrashes] at (wrapper dynamic-method) System.Object.60(intptr,intptr,intptr) [AppCenterCrashes] at (wrapper native-to-managed) System.Object.60(intptr,intptr,intptr)
When I look in AppCenter, it logs the exception ONLY with the bad stack trace. So that's a problem... The other problem is that it completely ignored my Crashes.TrackError call, the exception with the good stack trace and properties set doesn't get added to AppCenter.
What am I missing?