CrashReporter.NET.Official 1.5.3

.NET Framework 2.0
There is a newer version of this package available.
See the version list below for details.
Install-Package CrashReporter.NET.Official -Version 1.5.3
dotnet add package CrashReporter.NET.Official --version 1.5.3
<PackageReference Include="CrashReporter.NET.Official" Version="1.5.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CrashReporter.NET.Official --version 1.5.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CrashReporter.NET.Official, 1.5.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CrashReporter.NET.Official as a Cake Addin
#addin nuget:?package=CrashReporter.NET.Official&version=1.5.3

// Install CrashReporter.NET.Official as a Cake Tool
#tool nuget:?package=CrashReporter.NET.Official&version=1.5.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

How it works

CrashReporter.NET uses the exception information like stack trace, exception type, message, source, .NET CLR version, OS version and application version to generate the crash report and send it to developer using email. It uses DoctorDump service (http://drdump.com) to send email to developer. Developers can use their SMTP server to send email too.

Using the code

Windows Forms Application

First thing you need to do is subscribe to Application.ThreadException and AppDomain.CurrentDomain.UnhandledException in your Program.cs file as shown below.

internal static class Program
{
    /// <summary>
    ///     The main entry point for the application.
    /// </summary>
    [STAThread]
    private static void Main()
    {
        Application.ThreadException += ApplicationThreadException;

        AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new FormMain());
    }

    private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
    {
        ReportCrash((Exception)unhandledExceptionEventArgs.ExceptionObject);
        Environment.Exit(0);
    }

    private static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)
    {
        ReportCrash(e.Exception);
    }

    public static void ReportCrash(Exception exception,  string developerMessage = "")
    {
        var reportCrash = new ReportCrash("Email where you want to receive crash reports.")
        {
            DeveloperMessage = developerMessage
        };

        reportCrash.Send(exception);
    }
}

Just set the ToEmail in above example with your email to start receiving crash reports.

If you want to handle exception report for individual exception with special message you can do it like shown below.

const string path = "test.txt";
try
{
    if (!File.Exists(path))
    {
        throw new FileNotFoundException(
            "File Not found when trying to write argument exception to the file", argumentException);
    }
}
catch (Exception exception)
{
    Program.ReportCrash(exception, "Value of path variable is " + path);
}

WPF Application

First thing you need to do is subscribe to AppDomain.CurrentDomain.UnhandledException in your App.xaml.cs file as shown below.

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
        Application.Current.DispatcherUnhandledException += DispatcherOnUnhandledException;
        TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
    }

    private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
    {
        ReportCrash(unobservedTaskExceptionEventArgs.Exception);
        Environment.Exit(0);
    }

    private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs dispatcherUnhandledExceptionEventArgs)
    {
        ReportCrash(dispatcherUnhandledExceptionEventArgs.Exception);
        Environment.Exit(0);
    }

    private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
    {
        ReportCrash((Exception)unhandledExceptionEventArgs.ExceptionObject);
        Environment.Exit(0);
    }

    public static void ReportCrash(Exception exception, string developerMessage = "")
    {
        var reportCrash = new ReportCrash("Email where you want to receive crash reports.")
        {
            DeveloperMessage = developerMessage
        };
        reportCrash.Send(exception);
    }
}

Just set the ToEmail in above example with your email to start receiving crash reports.

If you want to handle exception report for individual exception with special message you can do it like shown below.

const string path = "test.txt";
try
{
    if (!File.Exists(path))
    {
        throw new FileNotFoundException(
            "File Not found when trying to write argument exception to the file", argumentException);
    }
}
catch (Exception exception)
{
    App.ReportCrash(exception, "Value of path variable is " + path);
}

Configuration Options

Send reports to your DrDump account

You can send crash report to you doctor dump account by adding following line in ReportCrash method of Program.cs file.

reportCrash.DoctorDumpSettings = new DoctorDumpSettings
{
    ApplicationID = new Guid("Application ID you received from DrDump.com"),
};

Just set the ApplicationID to ID you received from DrDump.com.

Capture whole screen instead of Application screen

You can take screenshot of whole screen instead of only application when application crashes by adding following line in ReportCrash method of Program.cs file.

reportCrash.CaptureScreen = true;
Product Versions
.NET Framework net20 net35 net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on CrashReporter.NET.Official:

Repository Stars
DaxStudio/DaxStudio
DAX Studio is a tool to write, execute, and analyze DAX queries in Power BI Desktop, Power Pivot for Excel, and Analysis Services Tabular.
chenxuuu/llcom
🛠功能强大的串口工具。支持Lua自动化处理、串口调试、串口监听、串口曲线、TCP测试、MQTT测试、编码转换、乱码恢复等功能
TheCheatsrichter/Gw2_Launchbuddy
Custom launcher generator for the video game Guild Wars 2.
rudi-krsoftware/open-retail
Perangkat lunak open source yang dikembangkan khusus untuk bidang usaha ritel, grosir, toko bangunan, toko komputer, toko buku, counter hp, pos, point of sale, kasir dan bidang usaha lainnya yang sejenis.
Version Downloads Last updated
1.6.0 5,751 1/2/2021
1.5.8 13,144 8/9/2019
1.5.7 6,916 3/7/2019
1.5.6 1,159 11/5/2018
1.5.5 1,795 6/21/2018
1.5.4 973 6/16/2018
1.5.3 2,343 11/16/2017
1.5.2 3,272 8/9/2017
1.5.1 2,869 9/7/2016

* Improved DPI awareness.
* Now if there is a crash on UI thread CrashReporter.NET will use current UI thread to show the crash report dialog.
* Now Visual Styles for Windows Forms will be enabled for WPF application to show the Crash Report form in native Windows Visual Style.
* Added Korean Language translation.