As part of the Telerik “Q1.2012 Beta” package for Windows Phone we are releasing a new set of "Application Building Blocks" components. You can find more info on the idea of Application Building Blocks here. Among these components is RadDiagnostics.


RadDiagnostcs component will enable you to receive crash reports, get specific debug and run-time information from your end users when an issue (ApplicationUnhandledException) in your application is encountered. When an exception occurs, a MessageBox dialog is displayed and users are asked to report the diagnostics data. The collected data contains rich information about the exception, device and runtime info. Optionally a screenshot of the current application state can be provided. Developers can also add custom data when an exception has occurred and to collect runtime logs.

We are already using this component in Telerik “Tasks” application for WindowsPhone and it has proved to be a very valuable helper in debugging and resolving application issues. I strongly recommend you to add such an error reporting component to all of your applications.

Here is how the default user experience for the end users looks like:
Error handling in WindowsPhone/WinRt mobile applications
When users click on the “Yes” button they will be able to send an email message pre-filled with all the data collected from RadDiagnostics.
This is the default user experience. Developers can customize the displayed message and also have an option to skip the message, to get the data and to send it automatically to their own web service for analyzing (this requires additional development and is not provided out of the box).

The usage of the control is quite simple and intuitive:

RadDiagnostics diagnostics = new RadDiagnostics();
diagnostics.EmailTo = “”;

This initialization code should be added in the App constructor.

To create a custom action and to get notified when an exception has occurred, you can subscribe to the ExceptionOccured event:

radDiagnostics.ExceptionOccurred += new EventHandler<ExceptionOccurredEventArgs>(RadDiagnostics_ExceptionOccurred);
private void RadDiagnostics_ExceptionOccurred(object sender, ExceptionOccurredEventArgs e)
  //e.Cancel = true; setting Cancel to true will prevent the message box from displaying.
   // add any custom code here, like reporting to a custom web service
  //SendDiagnosticsToWebService((sender as RadDiagnostics).DiagnosticInfo);

Diagnostic Data

You are maybe now curious to see what data you will receive when an error is encountered. Here is a sample error report:

Navigation is not allowed when the task is not in the foreground. Error: -2147220990
   at Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr(Int32 hr)
   at Microsoft.Phone.Scheduler.SystemNotificationInterop.CreateNotification(ScheduledAction action)
   at Microsoft.Phone.Scheduler.ScheduledActionService.Add(ScheduledAction action)
   at Telerik.WindowsPhone.Tasks.ApplicationHelpers.ScheduleMasterTileUpdateAgent()
   at Telerik.WindowsPhone.Tasks.App.Application_Launching(Object sender, LaunchingEventArgs e)
   at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()
   at Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()
[OccurrenceDate]:[Tue, 31 Jan 2012 12:41:48 GMT]
[AppInstallDate]:[Sun, 29 Jan 2012 19:00:42 GMT]
[AppPreviousRunDate]:[1/29/2012 2:01:54 PM]
[OSVersion]:[Microsoft Windows CE 7.10.7720]

As you can see we are collecting a lot of data which will be useful for you when debugging the problem. If this is not sufficient enough RadDiagnostics can be used as a simple logger to collect any runtime info you are providing. Here is a simple usage of the logging feature:

radDiagnostics.AddDebugInfo(String.Format("filterData = {0}", filterDate));

In order to keep the performance of your application high logs will contain only the last 1Mb of data. Please keep this in mind when using this feature.

Another cool feature (and my favorite one I must admit :)) of RadDiagnostics is how the mail Subject is composed. Apart from the obvious info – ApplicationName and ApplicationVersion – it contains the Hashcode of the Stack Trace!!! This allows you to group the mails you receive and see which error is occurring most often – thus seeing the top priority issues.

Here is how my inbox looks like for the Tasks application crash reports:

I hope that this component will be very useful for you as it is for us in Tasks application. Please give it a try during the beta period and let us know if you have suggestions for enhancements.

You can also find me on twitter @valiostoychev  – I’ll be happy to discuss any feedback you have!

About the Author

Valio Stoychev

Valentin Stoychev (@ValioStoychev) for long has been part of Telerik and worked on almost every UI suite that came out of Telerik. Valio now works as a Product Manager and strives to make every customer a successful customer.