Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 17286 [details]
Example project that hard crashes when ran
Certain exceptions that occur in Apple APIs hard crash our app without getting caught at any level. Attached is an example project that hard crashes the app from simply setting an NSComboBox index to -1.
We prefer to show unhandled exceptions in a user friendly dialog that allows support tickets to be submitted, and let the user continue using the app. Some exceptions do force the app to shutdown but in most cases we can still show an error dialog or at least log some data then restart the app.
The example project attempts to catch the exception with the following methods:
* Setting NSSetUncaughtExceptionHandler (https://developer.apple.com/reference/foundation/1409609-nssetuncaughtexceptionhandler?language=objc)
* Subscribing to AppDomain.CurrentDomain.UnhandledException
* Try/catch around NSApplication.Main(args) or NSApplication.SharedApplication.Run()
The crash log: https://gist.github.com/zone117x/dd45be244c05c415598bca5f343478d2
It looks like there is some related handling going on here: https://github.com/xamarin/xamarin-macios/search?utf8=%E2%9C%93&q=xamarin_throw_ns_exception
But not really sure what that's doing or how to use it.
Created attachment 17324 [details]
XCode Cocoa proj with same code as example by bug reporter.
I could reproduce this issue and noted that the native exception is not propogated to the managed side of things. I see that this is expected most of the time as per some posts I found from Rolf   and others  about this.
However, testing a native Obj-C Cocoa app (attached) that uses the exact same code does not crash the app but rather generates a warning and the app continues to run.
This crashing behavior is a blocker for us. Seems like the issue should be marked higher priority considering there are probably lots of Xamarin.Mac apps deployed in the field right now hard crashing more often than comparable objc/swift apps. These are the kind of problems are turn devs away from the Xamarin ecosystem.
Apologies for the delay in response, I was out of the office.
The difficulty in handling "native" objective-c exceptions in C# applications has been a pain point we've know about for awhile. Solving it was non-trivial, but in Cycle8 (currently in Beta, will hit stable within the next day or two) we have a solution.
If you go into your project projects, mac build and add the following to your additional mmp arguments
we will catch the native exception and convert it to a managed one. There will be a minor performance hit, larger on 32-bit.
In the future, we may default this on, but for right now it'll be opt in.
Please reopen if that doesn't solve your use case.