问题描述
我在野外有一个讨厌的bug,我不能把我的手指放在它上面。是否有一种方法可以使用全局Try / Catch块,或者一种方法来处理Monotouch中未被处理的任何异常。我可以在try catch中包装 UIApplication.Main(args)
在异常被捕获之后,Id喜欢显示一个UIAlertView显示结果。
任何帮助?
您可以在try {} catch {}中包装UIApplication.Main(args),但是在这一点上您将无法显示UIAlertView,因为我们已经解开了整个堆栈,包括所有的UI。您可以做的是将例外记录到应用程序包的文档文件夹中的崩溃文件,并在下次启动时将其上传到Web服务。
的人也在研究MonoTouch支持,这可能值得研究。
I am having a nasty bug show up in the wild, and I can't put my finger on it. Is there a way to have a Global Try/Catch block, or a way to handle any exception that is unhanded in Monotouch.
Can I just wrap UIApplication.Main(args)
in a try catch?
After the exception is caught, Id like to show a UIAlertView to display the results.
Any help?
You can wrap UIApplication.Main (args) in a try {} catch {} but you will not be able to show a UIAlertView at that point, since we've unwound the entire stack including all the UI. What you could do is log the exception to a crash file in the Documents folder of your application bundle, and show that on the next launch or upload it to a web service.
The Exceptioneer guys were working on MonoTouch support as well, which might be worth looking into.
这篇关于Monotouch全局异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!