OneTrueError and the WinForms/WPF integration

OneTrueError is a new startup which also is a member of Microsoft BizSpark. This post is about the client library for WinForms/WPF. It will catch and handle all uncaught exceptions automatically. The errors are also uploaded to our site for analysis to enable us to suggest possible solutions

To get started you need to have an account at onetrueerror.com and download our nuget-package OneTrueError.winforms. Once you’ve completed that you’ll only have to add these lines of code to your Program.cs.

OneTrue.Configuration.Credentials("appKeyThatYouGot", 
                                  "sharedSecretThatYouGot");
OneTrue.Configuration.CatchWinFormsExeptions();

Now we’ll be able to detect and handle all uncaught exceptions.

Do something in your application which would throw an exception (or simply generate one to try the library out):

private void button1_Click(object sender, EventArgs e)
{
    throw new DataException("Failed to connect to database.");
}

Once the exception is thrown you should get a dialog that looks like this:

basic

Configuration

We provide several options for configuration. These options are the same for all our integration libraries and it’s therefore easy to add OneTrueError to all applications based on the different Microsoft frameworks.

For starters you can configure whether the user should be asked for permission before uploading the reports. In the WinForms/WPF library that simply changes the form to use two buttons. One to report and one to just close the window:

OneTrue.Configuration.AskUserForPermission = true;
OneTrue.Configuration.Credentials("00ba6c30-198e-4383-9301-b21b7a9b1e68",
                                  "bd7b3ff3-81c7-41fa-908d-03d48fafc494");
OneTrue.Configuration.CatchWinFormsExeptions();

ask-for-permission

Next you can ask the user for additional information to help you resolve the error faster.

OneTrue.Configuration.AskUserForDetails = true;
OneTrue.Configuration.Credentials("00ba6c30-198e-4383-9301-b21b7a9b1e68",
                                  "bd7b3ff3-81c7-41fa-908d-03d48fafc494");
OneTrue.Configuration.CatchWinFormsExeptions();

ask-for-details

Finally you can let user to enter their email address to be able to track progress of the error (and to add additional feedback).

OneTrue.Configuration.AskForEmailAddress = true;
OneTrue.Configuration.Credentials("00ba6c30-198e-4383-9301-b21b7a9b1e68",
                                  "bd7b3ff3-81c7-41fa-908d-03d48fafc494");
OneTrue.Configuration.CatchWinFormsExeptions();

email

You can of course combine them:

combination

Customization

You do not have to use our error dialog. You can create your own one. Just create a new form like this (the constructor is of course not required):

public partial class CustomErrorDialog : Form
{
    public CustomErrorDialog(string exceptionMessage)
    {
        InitializeComponent();
        lblError.Text = exceptionMessage;
    }
}

Then assign it to the OneTrueError library:

OneTrue.Configuration.SetErrorForm(formsContext => new CustomErrorDialog(formsContext.Context.Exception.Message));

Result:

custom-dialog

Summary

This article only went through the client side of OneTrueError. There server side is much more interesting. Register at onetrueerror.com and find out why.