Wednesday, November 20, 2013

How to Capture Unhandled Exceptions using Xamarin Android and C#

I looked and looked for a good way to catch unhandled exceptions in my android app that I wrote using Xamarin for Visual Studio. I am not interested in sending them to a webserver at this time, I just want to catch them and log them. I came across this post and became discouraged,

http://mono-for-android.1047100.n5.nabble.com/Catch-all-the-exceptions-td5165993.html

However, this is a solution I came up with to capture unhandled exceptions using Xamarin Android and C# that works for me so I thought I would share it.

Implementing the application class allowed for a global unhandled exception catcher.

The full source is available at
https://github.com/Xandroid4Net/MyExamples/tree/master/UnhandledExceptionExample