question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xamarin Android: Unhandled exceptions never received in Sentry console

See original GitHub issue

I’m not sure how to configure the new unified Sentry Sdk in order for it to capture unhandled exceptions. I’ve spent a day attempting to get it to send out unhandled exceptions, but they don’t seem to work properly in a Xamarin Android app.

The initialization of Sentry is performed like this:

SentryClient = SentrySdk.Init(o => {
    o.Dsn = new Dsn(AppConfig.SentryDSN);
    o.Debug = true;
});

As per comments in #96 I added:

AppDomain.CurrentDomain.ProcessExit += (object sender, EventArgs e) => {
    SentryClient.Dispose();
};

Then, elsewhere in the Android code (an Activity for example), given the following lines, I get two different results:

SentrySdk.CaptureException(new Exception("Manually thrown exception")); // this makes it to Sentry.
throw new Exception("Unhandled exception"); // adding this line causes neither exception to make it to Sentry.

In the application console, I can see information regarding the event:

Info: Capturing event.
Debug: Running processor on exception: Unhandled exception
Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
Debug: Running main event processor on: Event <event-id>
Debug: Event queued up.
Info: Disposing the Hub.
Debug: Disposing SentryClient.
Debug: Disposing BackgroundWorker.
Debug: Event <event-id> in-flight to Sentry. #0 in queue.
Debug: Disposing scope.
Debug: Disposing SentryClient.

Randomly (at some point after playing around with various configurations), the Sentry console has received an event with <unlabeled event> as its title, and “Discarded invalid value for parameter ‘exception’” in the processing errors, but we are unable to determine if this is unhandled or not?

Additionally, if I use o.DisableAppDomainUnhandledExceptionCapture() and set up my own exception handler on AppDomain these aren’t sent either!

Is there anything obvious that I am doing wrong? Based on the documentation I don’t think there’s much more I should be doing.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
Didscommented, Oct 10, 2019

Sentry actually works for me in Xamarin.Forms. Only tested on iOS so far, but exceptions are being captured.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin | Sentry Documentation
Xamarin.Forms -Version 1.5.2 # If you are not using Xamarin. ... You can verify Sentry is capturing unhandled exceptions by raising an exception....
Read more >
Xamarin Forms, how to log unhandled exception
I have following code in my Xamarin Forms project. I used SentryErrorLog to log exception and saved exception message to pp device locally....
Read more >
Xamarin Android doesn't include exception message in ...
I have a Xamarin Forms Android app on the Google Play store. I've received a few crash reports (Google Console --> Android Vitals ......
Read more >
How to Catch All Exceptions in C# & Find All Application ...
Catch all exceptions in your application with a C# global exception handler and other exception-handling methods.
Read more >
Monitoring errors in Xamarin apps
We will show you how to handle errors using both native error handling in Xamarin and using Rollbar, which is a dedicated service...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found