I am trying to implement a useful general exception handler for my MonoTouch code.
If I attach a handler to AppDomain.CurrentDomain.UnhandledException
, there is no stack trace present at all, i.e. the .StackTrace property is null or empty.
If I wrap my UIApplication.Main(args)
call in try {} catch {}
, the stack trace doesn't contain any useful information:
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in <filename unknown>:0
at MyNamespace.MyProduct.MyProject.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0
i.e. it doesn't go any deeper than the Main() method where I caught the exception.
Any ideas how I can get some more useful information in the stack trace at all, or is it all optimised away completely by the AOT compilation? (The stack trace is as expected in debug mode.)
Use the --debug command line option or select configuration "Debug|iPhone" in MonoDevelop.
Remember that this option will result in slower execution, but you will get line numbers in exceptions etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With