These are the things that should be done, in order to take advantage of the features of RadDiagnostics:
First, a reference to the following assemblies has to be added:
- Telerik.Windows.Core.dll
- Telerik.Windows.Controls.Primitives.dll
Then, the ApplicationUsageHelper has to be initialized. This helper actually creates
most of the information that is included in the DiagnosticInfo that is sent. The initialization
is done with the Init method, which should be called on the launching of the application. In
Application_Activated the method OnApplicationActivated should be called to ensure that the
ApplicationUsageHelper will be initialized even after the application has been tombstoned.
Here is an example with excerpt from the App.xaml.cs:
CopyC#
private void Application_Launching(object sender, LaunchingEventArgs e)
{
ApplicationUsageHelper.Init("2.2");
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
ApplicationUsageHelper.OnApplicationActivated();
}
After that, a new RadDiagnostics instance has to be declared. The usage is quite simple and intuitive:
CopyC#
radDiagnostics = new RadDiagnostics();
radDiagnostics.EmailTo = "Me@MyCompany.com";
radDiagnostics.Init();
The initialization code should be added to the App constructor.
Now when an ApplicationUnhandledException is encountered the user will
see a message box asking them if they would like to send a report.
Here is how the default user experience for the end users looks like:
You can stop the message box from displaying and create a custom action that will be executed
when an exception is encountered. This can be done by subscribing
to the ExceptionOccurred event:
CopyC#
radDiagnostics.ExceptionOccurred += new EventHandler<ExceptionOccurredEventArgs>(RadDiagnostics_ExceptionOccurred);
private void RadDiagnostics_ExceptionOccurred(object sender, ExceptionOccurredEventArgs e)
{
e.Cancel = true;
}