Bug 2461 - There's no place to trap all uncaught exceptions
Summary: There's no place to trap all uncaught exceptions
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.0
Hardware: PC All
: Normal normal
Target Milestone: 5.1
Assignee: Marek Habersack
URL:
Depends on: 7634
Blocks:
  Show dependency tree
 
Reported: 2011-12-12 11:49 UTC by MikeFayer
Modified: 2015-03-12 23:07 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description MikeFayer 2011-12-12 11:49:08 UTC
In order to make an error-reporting feature, it's necessary to have some hook for catching all uncaught exceptions from all threads. 

The usual route for accomplishing this is the AppDomain.UnhandledException event. However, as described here:

http://androidapi.xamarin.com/index.aspx?link=E%3aAndroid.Runtime.AndroidEnvironment.UnhandledExceptionRaiser


This event doesn't work. Without a suitable replacement, there's no decent way to create error-reporting functionality with MD.

I also tried to use AndroidEnvironment.UnhandledExceptionRaiser but this is not an appropriate API because it will only work for code that was (at least indirectly) invoked from java.
Comment 1 Rodrigo Kumpera 2011-12-13 00:05:33 UTC
Hi Mike,

Did you try the AppDomain.UnhandledException event? It's meant to solve exactly that. If it doesn't work, it might be the case we need to fix Mono for Android to properly use it.
Comment 2 MikeFayer 2011-12-13 06:08:02 UTC
Hi Rodrigo,

As I said, AppDomain.UnhandledException DOES NOT work. The reason for it not working is in your own documentation here:

http://androidapi.xamarin.com/index.aspx?link=E%3aAndroid.Runtime.AndroidEnvironment.UnhandledExceptionRaiser

"Note: You cannot rely on the AppDomain.UnhandledException event as managed exceptions are never unhandled in MonoDroid; they are always intercepted at the Android/managed boundary within a catch(Exception) block."
Comment 3 Jonathan Pobst 2011-12-14 18:41:45 UTC
No longer NEEDINFO.
Comment 4 Jonathan Pryor 2015-03-06 13:19:07 UTC
AppDomain.UnhandledException should work for uncaught exceptions from all threads, even Java threads, as of monodroid/db5b3820.
Comment 5 Alexandre Rocha Lima e Marcondes 2015-03-12 17:58:20 UTC
What monodroid/db5b3820 commit means to us mortals that cannot access the repo, any idea the release we are expected to see it?
Comment 6 Peter Collins 2015-03-12 18:10:28 UTC
@Alexandre This will be part of the next XA release (5.1). Early alpha builds for this release should be available within a month or so.
Comment 7 Alexandre Rocha Lima e Marcondes 2015-03-12 18:39:59 UTC
Thanks Peter,

Just for knowledge. Now I am using the Xamarin Android 5.0 Preview (which contains the Android Wear support)  that is available on http://developer.xamarin.com/guides/android/wear/installation/ .

Does the alpha you are referring to  includes all changes and support that are present on the version I am using? I need it due to this bugfix: https://bugzilla.xamarin.com/show_bug.cgi?id=25683#c12

By the way, are there any updates or channels I can configure on the version I am using it to be able to updated it? It keeps asking to "update" to a lower version.
Comment 8 Peter Collins 2015-03-12 23:07:38 UTC
@Alexandre The 5.0 preview you are using contains some, but not all of the features and fixes planned for the 5.1 release.

The alpha release for XA 5.1 will contain all of the changes and support for bug #25683 that you require.

To answer your last point, unfortunately when you are using a preview build from the web there is currently no way to prevent the updater from prompting you to "downgrade" to the version that is available in the specific updater channel that you are subscribed to.