Telerik blogs

[Please download the attached project with full source code available.]

Last week we released a Beta preview of Telerik RadControls for WindowsPhone. You can read more info on the 6 bright new components for Windows Phone here.

RadDiagnostics was one of the released components which received a lot of attention from the Windows Phone developers. This component is sending rich crash reports when an ApplicationUnhandledException has occurred. Read more about RadDiagnostics in this detailed blog post.

One of the features with which RadDiagnostics was created in mind is to allow developers to receive anonymous crash reports without user interaction. By default the control will display a message box notifying the users that an error has occurred and asking them to send the user reports. But sometimes developers do not want to notify users for application exceptions and also users may not be keen to send the data from their email accounts. Using a web service you are sure that all application errors will be reported to you (when users have internet connection).

In this case you can use RadDiagnostics to handle and collect the data on the device and to send this data to your webservice. To do this you need to handle the ExceptionOccured event of RadDiagnostics and to cancel it. Then you can get the data and send it.

radDiagnostics = new RadDiagnostics();
            radDiagnostics.EmailTo = "yourdevemail";
            radDiagnostics.ExceptionOccurred += new EventHandler<ExceptionOccurredEventArgs>(radDiagnostics_ExceptionOccurred);

In the ExceptionOccured event handler you should cancel the MessageBox, get the already generated data and send it to your web service:

void radDiagnostics_ExceptionOccurred(object sender, ExceptionOccurredEventArgs e)
    // settings Cancel to true will stop the message box from displaying
    e.Cancel = true;
    // add any cusomt code here, like a custom web service
    SendDiagnosticsToWebService((sender as RadDiagnostics).DiagnosticInfo);
private void SendDiagnosticsToWebService(string diagnosticInfo)
    DataCollectorServiceClient serviceClient = new DataCollectorService.DataCollectorServiceClient();
    serviceClient.CollectDataAsync(radDiagnostics.ApplicationName, radDiagnostics.ApplicationVersion, diagnosticInfo);

In the web service implementation you are free to do anything with the received data. You can simply send yourself an email or you can store it in database and build some sort of reports based on the data.

In the attached source I'm showing how to send an email - note that you must have the email functionality configured on the server where you are hosting the web service in order to be able to send emails.

I hope this article helps you build more robust applications for Windows Phone 7. If you have any other feedback - please do not hesitate to contact me.

You can also find me on twitter @valiostoychev.

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.



Comments are disabled in preview mode.