Error reporting for Windows Phone 7 : Little Watson (XNA version)

Recently I blogged about Error reporting for Windows Phone 7 : Little Watson but when I was using it for the Slime Sweeper V2 , i realised its not as simple as copying and paste the framework over to XNA and use it. We have to introduce some extra stuffs.

I built the XNA version for it. Appreciated the help given by Konaju Games on MSDN forum here and Andy Pennell who have written the original version of Little Watson.

We have to add Microsoft.Phone and System.Windows references into the project. The codes are similar but we do not have native MessageBox.Show and Application.Current.UnhandledException in the project like what we have on Silverlight project and hence we have to add them differently to the project.

In the constructor of the game, we have to add this code.

Application.Current.UnhandledException += (s, e) =>
{
if (!System.Diagnostics.Debugger.IsAttached)
{
try
{
LittleWatson.ReportException(e.ExceptionObject, GetType().Assembly.FullName);
}
catch
{
// We do not want to throw exceptions in our exception handler
}
}
};

and as for MessageBox.Show, I am using Guide.BeginShowMessageBox method.
http://msdn.microsoft.com/en-us/library/dd940233.aspx

Guide.BeginShowMessageBox

You can download the sample code which I have built here, the button will crash the application and when you try to go into the application again from the emulator, a messagebox will appear :
http://cid-29f099c37b76ca59.office.live.com/self.aspx/Blog/Code%20Guide/Windows%20Phone%207/LittleWatsonXNA.zip

If you have any feedback or question, feel free to contact me via the contact me form or email me at [email protected]