Search code examples
c#messagebox.net-framework-version

How to make an error messagebox that contains a button to show error details?


I want to use C# to make an error messagebox with an option to show details of the error just like the messagebox below:

enter image description here

Does anybody know how to make a messagebox like that?


Solution

  • According to the documentation, the dialog is not intended to be used directly:

    ThreadExceptionDialog

    However, it looks to me like you can use it like a standard dialog:

    try {
        // code
    }
    catch(Exception e) {
        var d = new ThreadExceptionDialog(e);
        d.ShowDialog();
    }
    

    If they hit continue I imagine you will drop out of ShowDialog and continue. If they press Quit I imagine execution stops. Easy to test.

    Of course it would only be a fairly easy job to put together your own version to use as you please and you would have total control over it.