Startup:
/// <summary>
/// On Start-up
/// </summary>
/// <param name="e">The start-up event arguments.</param>
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
Application.Current.DispatcherUnhandledException += DispatcherOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
var bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
Catchers:
/// <summary>
/// On unobserved task exception with the task scheduler.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="unobservedTaskExceptionEventArgs">The <see cref="UnobservedTaskExceptionEventArgs"/> instance containing the event data.</param>
private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
SendReport(unobservedTaskExceptionEventArgs.Exception);
Environment.Exit(0);
}
/// <summary>
/// On unhandled exception of the dispatcher.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="dispatcherUnhandledExceptionEventArgs">The <see cref="DispatcherUnhandledExceptionEventArgs"/> instance containing the event data.</param>
private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs dispatcherUnhandledExceptionEventArgs)
{
SendReport(dispatcherUnhandledExceptionEventArgs.Exception);
Environment.Exit(0);
}
/// <summary>
/// On unhandled exception of the current domain.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="unhandledExceptionEventArgs">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
SendReport((Exception)unhandledExceptionEventArgs.ExceptionObject);
Environment.Exit(0);
}
Sender:
/// <summary>
/// Sends the crash report.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="developerMessage">The developer message.</param>
/// <param name="silent">if set to <c>true</c> [silent].</param>
public static void SendReport(Exception exception, string developerMessage = "", bool silent = true)
{
var reportCrash = new ReportCrash("REMOVED")
{
DeveloperMessage = developerMessage,
Silent = silent
};
reportCrash.Send(exception);
}
Placing a breakpoint in the "SendReport" method and it's hit when a crash occurs.
Setting the variable "silent" to "false" opens the dialog on a crash, sends and receives fine.
Settings the variable "silent" to "true", breakpoint still hits like normal, no report is sent.
Have tried calling reportCrash.SendSilently(exception);
instead, same result.
Have tried adding "DoctorDumpSettings" to the "ReportCrash":
var reportCrash = new ReportCrash("REMOVED")
{
DeveloperMessage = developerMessage,
Silent = silent,
DoctorDumpSettings = new DoctorDumpSettings
{
ApplicationID = Guid.Parse("REMOVED"),
OpenReportInBrowser = true,
SendAnonymousReportSilently = silent
}
};
The "OpenReportInBrowser" also seems to not work when "reporting silently".