CrashReporter.NET.Official 1.5.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package CrashReporter.NET.Official --version 1.5.3
NuGet\Install-Package CrashReporter.NET.Official -Version 1.5.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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
#r "nuget: CrashReporter.NET.Official, 1.5.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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

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 Compatible and additional computed target framework versions.
.NET Framework net20 is compatible.  net35 is compatible.  net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 is compatible.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
chenxuuu/llcom
🛠功能强大的串口工具。支持Lua自动化处理、串口调试、串口监听、串口曲线、TCP测试、MQTT测试、编码转换、乱码恢复等功能
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.
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 13,699 1/2/2021
1.5.8 16,159 8/9/2019
1.5.7 7,307 3/7/2019
1.5.6 1,520 11/5/2018
1.5.5 2,493 6/21/2018
1.5.4 1,537 6/16/2018
1.5.3 2,988 11/16/2017
1.5.2 4,127 8/9/2017
1.5.1 3,705 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.