ravibpatel / CrashReporter.NET

Send crash reports of your classic desktop application developed using .NET Framework directly to your mail's inbox with full exception report, stack trace and screenshot.
MIT License
184 stars 74 forks source link

Send Silently Not Working (Windows, WPF) #22

Closed NextAlexM closed 5 years ago

NextAlexM commented 5 years ago

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".

ravibpatel commented 5 years ago

I will look into it.

ravibpatel commented 5 years ago

I can't reproduce the issue in test projects. Can you provide me example project where I can reproduce the issue?

NextAlexM commented 5 years ago

I can't reproduce the issue in test projects. Can you provide me example project where I can reproduce the issue?

Invited you to a private repo with a project of send silently not working

ravibpatel commented 5 years ago

@NextAlexM Can you test the latest version from here. It should fix the issue.

NextAlexM commented 5 years ago

@ravibpatel That's fixed it! Thanks!

ravibpatel commented 5 years ago

Updated NuGet package to v1.5.7.

bergi9 commented 5 years ago

Still not working if only use stmp (no DrDump) because the stmpClient.SendAsync(message, "CrashReport"); is trying to send asynchronous while the application exits faster than sending.

ravibpatel commented 5 years ago

@bergi9 Thanks for reporting. I will look into it asap.

bergi9 commented 5 years ago

@ravibpatel could you release it on nuget? thank you

ravibpatel commented 5 years ago

@bergi9 Can you test out to see if it working fine for you. If it works fine I will release it.

ravibpatel commented 5 years ago

@bergi9 You can download the new version from here.

bergi9 commented 5 years ago

yep works fine

ravibpatel commented 5 years ago

@bergi9 Published NuGet package for v1.5.8. You will be able to download it soon.