MonoDroid: Global Error Handler

孤人 提交于 2019-12-18 08:53:18

问题


Is there a way to create a global error handler for MonoDroid? My debugger is broken so I need a way to see the exception info while the application crashes.


回答1:


It seems that AndroidEnvironment.UnhandledExceptionRaiser is what you're looking for:

//that's a dirty-code example, do not use as-is! :)
AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
                {
                    File.AppendAllText("tmp.txt", args.Exception.ToString());
                };



回答2:


Most (all?) unhandled exceptions should end up in the Android debug log:

http://docs.xamarin.com/android/advanced_topics/android_debug_log




回答3:


Please look at my project, it can handle and submit error info. https://github.com/soundnRg/Crasher



来源:https://stackoverflow.com/questions/8683304/monodroid-global-error-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!