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.
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) =>
// We do not want to throw exceptions in our exception handler
and as for MessageBox.Show, I am using Guide.BeginShowMessageBox method.
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 :
If you have any feedback or question, feel free to contact me via the contact me form or email me at [email protected]
I was looking through some resources and found this interesting bit written by a Microsoft developer working for mobile. He written it for his personal use and he is kind enough to release it to the community.
What he really did was actually to call the methods he had written in Application_UnhandledException and RootFrame_NavigationFailed in App.xaml.cs and this code bit will actually send an email to the email you specific with the stack trace and the error.
Simple and useful!