public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler,
            ReportExceptionEventArgs reportExceptionEventArgs) : this() {
            var newHeight = Height;

            this.reportExceptionEventArgs = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            errorMessage.Text = reportExceptionEventArgs.Exception.Message;

            newHeight += errorMessage.Height - FontHeight;

            if (!reportExceptionEventArgs.ShowContinueCheckbox) {
                continueCheckBox.Visible = false;
                newHeight -= continueCheckBox.Height;
            }

            if (newHeight > Height)
                Height = newHeight;

            if (reportExceptionEventArgs.CanDebug) {
                unhandledExceptionHandler.DebuggerLaunched += OnDebuggerLaunched;
                debug.Visible = true;
                poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport) {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                    dontSendReport.Focus();
            }

            email.Text = RegistryHelper.TryReadHKLMRegistryString("Email");

            unhandledExceptionHandler.SendingReportFeedback += OnFeedback;
        }
 protected override void OnReportException(ReportExceptionEventArgs e)
 {
     using (ExceptionReportingForm form = new ExceptionReportingForm(this, e))
     {
         form.ShowDialog();
     }
 }
 protected override void OnReportException(ReportExceptionEventArgs e)
 {
     if (e.Exception.Message.StartsWith("*NO_UI*"))
     {
         ExceptionReportingForm.NoUi = true;
     }
     ExceptionReportingForm form = new ExceptionReportingForm(this, e);
     form.ShowDialog();
 }
        Tuple<string, bool> HandleAggregateException(AggregateException aggregrateException,
            ReportExceptionEventArgs et) {
            Tuple<string, bool> handled = null;
            foreach (var error in aggregrateException.Flatten().InnerExceptions) {
                if (handled == null || handled.Item1 == null)
                    handled = InternalHandler(error, et); // Does not set the loader to true
            }

            return handled;
        }
        protected override void OnReportException(ReportExceptionEventArgs e)
        {
            if (e.Exception.Message.StartsWith("*NO_UI*"))
            {
                ExceptionReportingForm.NoUi = true;
            }
            ExceptionReportingForm form = new ExceptionReportingForm(this, e);

            form.ShowDialog();
        }
        Tuple<string, bool> HandleReflectionTypeLoadException(ReflectionTypeLoadException e,
            ReportExceptionEventArgs et) {
            Tuple<string, bool> handled = null;
            foreach (var error in e.LoaderExceptions) {
                if (handled == null || handled.Item1 == null)
                    handled = InternalHandler(error, et, true);
            }

            return handled;
        }
        Tuple<string, bool> HandleCompositionError(CompositionException e, ReportExceptionEventArgs et) {
            Tuple<string, bool> handled = null;
            if (e.Errors == null)
                return handled;
            foreach (var error in e.Errors.Where(x => x.Exception != null)) {
                if (handled == null || handled.Item1 == null)
                    handled = InternalHandler(error.Exception, et, true);
            }

            return handled;
        }
 protected override void OnReportException(ReportExceptionEventArgs e)
 {
     for (int i = 0; i < 3; i++)
     {
         if (e.SendReport())
         {
             break;
         }
     }
     e.TryToContinue = true;
 }
        public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler, ReportExceptionEventArgs reportExceptionEventArgs) : this()
        {
            int newHeight = Height;

            this.reportExceptionEventArgs  = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            this.errorMessage.Text         = reportExceptionEventArgs.Exception.Message;

            newHeight += (this.errorMessage.Height - FontHeight);

            if (!reportExceptionEventArgs.ShowContinueCheckbox)
            {
                this.continueCheckBox.Visible = false;
                newHeight -= (this.continueCheckBox.Height);
            }

            if (newHeight > Height)
            {
                Height = newHeight;
            }

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += new EventHandler(OnDebuggerLaunched);
                debug.Visible     = true;
                poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                {
                    dontSendReport.Focus();
                }
            }

            switch (reportExceptionEventArgs.Exception.HelpLink)
            {
            //We don't ask for sending or not, we go directly to the email information
            //Used by SmartAssembly if the developer clicks the "Send Report" button from the Main Application
            case "{send}":
                reportExceptionEventArgs.TryToContinue = true;
                panelInformation.Visible = false;
                panelProxy.Visible       = true;
                saveAsFile2.Visible      = true;
                break;
            }

            this.proxy.Text = RegistryHelper.ReadHKLMRegistryString("Proxy");
            unhandledExceptionHandler.SendingReportFeedback += new SendingReportFeedbackEventHandler(OnFeedback);
        }
Exemple #10
0
        protected override void OnReportException(ReportExceptionEventArgs e)
        {
            Thread exceptionUiThread = new Thread(() =>
            {
                // Starts our exception dialog and handle all events (must be on STA thread)
                ExceptionReportingForm form = new ExceptionReportingForm(this, e);
                form.ShowDialog();
            });

            exceptionUiThread.SetApartmentState(ApartmentState.STA);
            exceptionUiThread.Start();
            exceptionUiThread.Join();
        }
        Tuple <string, bool> HandleAggregateException(AggregateException aggregrateException,
                                                      ReportExceptionEventArgs et)
        {
            Tuple <string, bool> handled = null;

            foreach (var error in aggregrateException.Flatten().InnerExceptions)
            {
                if (handled == null || handled.Item1 == null)
                {
                    handled = InternalHandler(error, et); // Does not set the loader to true
                }
            }

            return(handled);
        }
        Tuple <string, bool> HandleReflectionTypeLoadException(ReflectionTypeLoadException e,
                                                               ReportExceptionEventArgs et)
        {
            Tuple <string, bool> handled = null;

            foreach (var error in e.LoaderExceptions)
            {
                if (handled == null || handled.Item1 == null)
                {
                    handled = InternalHandler(error, et, true);
                }
            }

            return(handled);
        }
        public bool Handle(Exception exception, ReportExceptionEventArgs e = null) {
            var r = InternalHandler(exception, e);

            if (string.IsNullOrEmpty(r.Item1))
                return r.Item2;

            var moreInfo = FormatException(exception);

            if (e != null) {
                e.AddCustomProperty("Six.Handled", r.Item1);
                e.TryToContinue = false;
            }

            ExitMessageHandler(exception, r, moreInfo);

            return r.Item2;
        }
        Tuple <string, bool> HandleCompositionError(CompositionException e, ReportExceptionEventArgs et)
        {
            Tuple <string, bool> handled = null;

            if (e.Errors == null)
            {
                return(handled);
            }
            foreach (var error in e.Errors.Where(x => x.Exception != null))
            {
                if (handled == null || handled.Item1 == null)
                {
                    handled = InternalHandler(error.Exception, et, true);
                }
            }

            return(handled);
        }
Exemple #15
0
        public void ReportExceptionTag_ShouldLog()
        {
            FailOnErrors = false;

            string message = "Should log exception";

            UntaggedLogging.ReportExceptionTag(0, Categories.ArgumentValidation, new ArgumentNullException(), message);

            Assert.Equal(1, LoggedEvents.Count);
            ReportExceptionEventArgs exceptionEventArgs = LoggedEvents[0] as ReportExceptionEventArgs;

            Assert.NotNull(exceptionEventArgs);
            Assert.Equal(message, exceptionEventArgs.Message);
            Assert.Equal(Levels.Error, exceptionEventArgs.Level);
            Assert.NotNull(exceptionEventArgs.Exception);
            Assert.Equal(typeof(ArgumentNullException), exceptionEventArgs.Exception.GetType());
            Assert.Equal(Categories.ArgumentValidation, exceptionEventArgs.CategoryId);
        }
        protected override void OnReportException(ReportExceptionEventArgs e) {
            LogError(e.Exception);
            TryAddFullExceptionTrace(e);
            TryAddSystemInfo(e);

            // TODO: Find the ReportId... and include it..

            var route = new KnownExceptions().Handle(e.Exception, e);

            if (route) {
                // Route on to SA
                var form = new ExceptionReportingForm(this, e);
                form.ShowDialog();
            } else {
                // Lets just try to continue...
                e.TryToContinue = true;
            }
        }
Exemple #17
0
        public ExceptionReportingForm(UnhandledExceptionViaEmailHandler unhandledExceptionHandler, ReportExceptionEventArgs reportExceptionEventArgs)
        {
            InitializeComponent();

            int newHeight = Height;

            this.reportExceptionEventArgs  = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            errorMessage.Text = reportExceptionEventArgs.Exception.Message;

            newHeight += (errorMessage.Height - FontHeight);

            if (!reportExceptionEventArgs.ShowContinueCheckbox)
            {
                continueCheckBox.Visible = false;
                newHeight -= (continueCheckBox.Height);
            }

            if (newHeight > Height)
            {
                Height = newHeight;
            }

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += new EventHandler(OnDebuggerLaunched);
                debug.Visible = true;
                if (debug.Left < powered.Right)
                {
                    powered.Visible = false;
                }
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                {
                    dontSendReport.Focus();
                }
            }

            unhandledExceptionHandler.SendingReportViaEmailFeedback += new SendingReportViaEmailFeedbackEventHandler(OnFeedback);
        }
        public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler,
                                      ReportExceptionEventArgs reportExceptionEventArgs) : this()
        {
            var newHeight = Height;

            this.reportExceptionEventArgs  = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            errorMessage.Text = reportExceptionEventArgs.Exception.Message;

            newHeight += errorMessage.Height - FontHeight;

            if (!reportExceptionEventArgs.ShowContinueCheckbox)
            {
                continueCheckBox.Visible = false;
                newHeight -= continueCheckBox.Height;
            }

            if (newHeight > Height)
            {
                Height = newHeight;
            }

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += OnDebuggerLaunched;
                debug.Visible     = true;
                poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                {
                    dontSendReport.Focus();
                }
            }

            email.Text = RegistryHelper.TryReadHKLMRegistryString("Email");

            unhandledExceptionHandler.SendingReportFeedback += OnFeedback;
        }
        void TryAddSystemInfo(ReportExceptionEventArgs e) {
            try {
                e.AddCustomProperty("Elevation Status", (!new UacHelper().CheckUac()).ToString());
            } catch {}
            try {
                e.AddCustomProperty("SEMVER", GetProductVersion());
            } catch {}
            try {
                e.AddCustomProperty("Uptime", (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalSeconds + "s");
            } catch {}
            // TODO
            /*
            try {
                e.AddCustomProperty("IsPremium", KnownExceptions.IsPremium);
            } catch { }
            try {
                e.AddCustomProperty("UserId", KnownExceptions.UserId);
            } catch { }
*/
        }
        public bool Handle(Exception exception, ReportExceptionEventArgs e = null)
        {
            var r = InternalHandler(exception, e);

            if (string.IsNullOrEmpty(r.Item1))
            {
                return(r.Item2);
            }

            var moreInfo = PrettyExceptions.FormatException(exception);

            if (e != null)
            {
                e.AddCustomProperty("Six.Handled", r.Item1);
                e.TryToContinue = false;
            }

            ExitMessageHandler(exception, r, moreInfo);

            return(r.Item2);
        }
Exemple #21
0
        protected override void OnReportException(ReportExceptionEventArgs e)
        {
            LogError(e.Exception);
            TryAddFullExceptionTrace(e);
            TryAddSystemInfo(e);

            // TODO: Find the ReportId... and include it..

            var route = new KnownExceptions().Handle(e.Exception, e);

            if (route)
            {
                // Route on to SA
                var form = new ExceptionReportingForm(this, e);
                form.ShowDialog();
            }
            else
            {
                // Lets just try to continue...
                e.TryToContinue = true;
            }
        }
Exemple #22
0
        void TryAddSystemInfo(ReportExceptionEventArgs e)
        {
            try {
                e.AddCustomProperty("Elevation Status", (!new UacHelper().CheckUac()).ToString());
            } catch {}
            try {
                e.AddCustomProperty("SEMVER", GetProductVersion());
            } catch {}
            try {
                e.AddCustomProperty("Uptime", (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalSeconds + "s");
            } catch {}
            // TODO

            /*
             * try {
             *  e.AddCustomProperty("IsPremium", KnownExceptions.IsPremium);
             * } catch { }
             * try {
             *  e.AddCustomProperty("UserId", KnownExceptions.UserId);
             * } catch { }
             */
        }
Exemple #23
0
        public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler, ReportExceptionEventArgs reportExceptionEventArgs)
            : this()
        {
            int newHeight = Height;

            this.reportExceptionEventArgs  = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            this.errorMessage.Text         = reportExceptionEventArgs.Exception.Message;
            this.header1.Text = string.Format("{1} has encountered a problem.{0}We are sorry for the inconvenience.", Environment.NewLine, UnhandledExceptionHandler.ApplicationName);
            this.header2.Text = string.Format("Please wait while {0} sends the report to {1} through the Internet.", UnhandledExceptionHandler.ApplicationName, UnhandledExceptionHandler.CompanyName);
            this.header3.Text = string.Format("Do you want to be contacted by {0} regarding this problem?", UnhandledExceptionHandler.CompanyName);
            this.label3.Text  = string.Format("If you want to be contacted by {0} regarding this error, please provide your e-mail address. This information will not be used for any other purpose.", UnhandledExceptionHandler.CompanyName);
            //this.pleaseTellMessage.Text = string.Format("To help improve the software you use, {0} is interested in learning more about this error. We have created a report about the error for you to send to us.", UnhandledExceptionHandler.CompanyName);

            foreach (var key in reportExceptionEventArgs.Exception.Data.Keys)
            {
                reportExceptionEventArgs.AddCustomProperty(string.Format("Data [{0}]", key.ToString()), reportExceptionEventArgs.Exception.Data[key].ToString());
            }

            newHeight += (this.errorMessage.Height - FontHeight);

            if (!reportExceptionEventArgs.CanContinue)
            {
                this.continueCheckBox.Visible = false;
                newHeight -= (this.continueCheckBox.Height);
            }

            if (newHeight > Height)
            {
                Height = newHeight;
            }

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += new EventHandler(OnDebuggerLaunched);
                debug.Visible = true;
                //poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                {
                    dontSendReport.Focus();
                }
            }

            this.email.Text = RegistryHelper.ReadHKLMRegistryString("Email");

            unhandledExceptionHandler.SendingReportFeedback += new SendingReportFeedbackEventHandler(OnFeedback);

            // GFH
            //if (WebProxy.Credentials != null)
            unhandledExceptionHandler.SetProxy(WebProxy);

            string reportedExceptions = RegistryHelper.ReadHKLMRegistryString("ReportedExceptions");
            string currentVersion;

            try
            {
                currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (!reportedExceptions.StartsWith(currentVersion))
                {
                    reportedExceptions = currentVersion + ":";
                }
            }
            catch
            {
                currentVersion = "";
            }
            string newHashCode = GetExceptionHashCode(reportExceptionEventArgs.Exception).ToString();

            // Force reporting of first-time exceptions
            if (reportedExceptions.Contains(newHashCode))
            {
                //labelRequiredInfo.Visible = false;
                dontSendReport.Enabled = true;
                cancelSending.Enabled  = true;
                saveAsFile.Enabled     = true;
            }
            else
            {
                //labelRequiredInfo.Visible = true;
                //dontSendReport.Enabled = false;
                //cancelSending.Enabled = false;
                //saveAsFile.Enabled = false;

                // Temp: Don't force user to send new message. These 4 lines below are repeated above, and should be removed once we decide what to do going forward.
                //labelRequiredInfo.Visible = false;
                dontSendReport.Enabled = true;
                cancelSending.Enabled  = true;
                saveAsFile.Enabled     = true;

                RegistryHelper.SaveHKLMRegistryString("ReportedExceptions", reportedExceptions + "," + newHashCode);
            }
            if (NoUi)
            {
                panelInformation.Visible = false;
                continueSendReport_Click(null, null);
            }
        }
Exemple #24
0
 /// <summary>
 /// Forward exceptions from the event handler to the logger
 /// </summary>
 private static void OnReportedException(object sender, ReportExceptionEventArgs args)
 {
     ReportExceptionBuffer.ReportException(args.ReportedException);
 }
 static void TryAddFullExceptionTrace(ReportExceptionEventArgs e) {
     try {
         e.AddCustomProperty("Full exception trace", PrettyExceptions.FormatException(e.Exception));
     } catch {}
 }
        public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler, ReportExceptionEventArgs reportExceptionEventArgs)
            : this()
        {
            int newHeight = Height;

            this.reportExceptionEventArgs = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            this.errorMessage.Text = reportExceptionEventArgs.Exception.Message;

            foreach (var key in reportExceptionEventArgs.Exception.Data.Keys)
                reportExceptionEventArgs.AddCustomProperty(string.Format("Data [{0}]", key.ToString()), reportExceptionEventArgs.Exception.Data[key].ToString());

            newHeight += (this.errorMessage.Height - FontHeight);

            if (!reportExceptionEventArgs.CanContinue)
            {
                this.continueCheckBox.Visible = false;
                newHeight -= (this.continueCheckBox.Height);
            }

            if (newHeight > Height) Height = newHeight;

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += new EventHandler(OnDebuggerLaunched);
                debug.Visible = true;
                poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus) dontSendReport.Focus();
            }

            this.email.Text = RegistryHelper.ReadHKLMRegistryString("Email");

            unhandledExceptionHandler.SendingReportFeedback += new SendingReportFeedbackEventHandler(OnFeedback);

            // GFH
            //if (WebProxy.Credentials != null)
            unhandledExceptionHandler.SetProxy(WebProxy);

            string reportedExceptions = RegistryHelper.ReadHKLMRegistryString("ReportedExceptions");
            string currentVersion;

            try
            {
                currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (!reportedExceptions.StartsWith(currentVersion))
                    reportedExceptions = currentVersion + ":";
            }
            catch
            {
                currentVersion = "";
            }
            string newHashCode = GetExceptionHashCode(reportExceptionEventArgs.Exception).ToString();

            if (reportedExceptions.Contains(newHashCode))
            {
                labelRequiredInfo.Visible = false;
                dontSendReport.Enabled = true;
                cancelSending.Enabled = true;
                saveAsFile.Enabled = true;
            }
            else
            {
                labelRequiredInfo.Visible = true;
                dontSendReport.Enabled = false;
                cancelSending.Enabled = false;
                saveAsFile.Enabled = false;
                RegistryHelper.SaveHKLMRegistryString("ReportedExceptions", reportedExceptions + "," + newHashCode);
            }
        }
 private void client_ReportException(object sender, ReportExceptionEventArgs e)
 {
     log.Error(e.Error.Message, e.Error);
 }
        public ExceptionReportingForm(UnhandledExceptionHandler unhandledExceptionHandler, ReportExceptionEventArgs reportExceptionEventArgs)
            : this()
        {
            int newHeight = Height;

            this.reportExceptionEventArgs  = reportExceptionEventArgs;
            this.unhandledExceptionHandler = unhandledExceptionHandler;
            this.errorMessage.Text         = reportExceptionEventArgs.Exception.Message;

            foreach (var key in reportExceptionEventArgs.Exception.Data.Keys)
            {
                reportExceptionEventArgs.AddCustomProperty(string.Format("Data [{0}]", key.ToString()), reportExceptionEventArgs.Exception.Data[key].ToString());
            }

            newHeight += (this.errorMessage.Height - FontHeight);

            if (!reportExceptionEventArgs.CanContinue)
            {
                this.continueCheckBox.Visible = false;
                newHeight -= (this.continueCheckBox.Height);
            }

            if (newHeight > Height)
            {
                Height = newHeight;
            }

            if (reportExceptionEventArgs.CanDebug)
            {
                unhandledExceptionHandler.DebuggerLaunched += new EventHandler(OnDebuggerLaunched);
                debug.Visible     = true;
                poweredBy.Visible = false;
            }

            if (!reportExceptionEventArgs.CanSendReport)
            {
                sendReport.Enabled = false;
                if (dontSendReport.CanFocus)
                {
                    dontSendReport.Focus();
                }
            }

            this.email.Text = RegistryHelper.ReadHKLMRegistryString("Email");

            unhandledExceptionHandler.SendingReportFeedback += new SendingReportFeedbackEventHandler(OnFeedback);

            // GFH
            //if (WebProxy.Credentials != null)
            unhandledExceptionHandler.SetProxy(WebProxy);

            string reportedExceptions = RegistryHelper.ReadHKLMRegistryString("ReportedExceptions");
            string currentVersion;

            try
            {
                currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                if (!reportedExceptions.StartsWith(currentVersion))
                {
                    reportedExceptions = currentVersion + ":";
                }
            }
            catch
            {
                currentVersion = "";
            }
            string newHashCode = GetExceptionHashCode(reportExceptionEventArgs.Exception).ToString();

            if (reportedExceptions.Contains(newHashCode))
            {
                labelRequiredInfo.Visible = false;
                dontSendReport.Enabled    = true;
                cancelSending.Enabled     = true;
                saveAsFile.Enabled        = true;
            }
            else
            {
                labelRequiredInfo.Visible = true;
                dontSendReport.Enabled    = false;
                cancelSending.Enabled     = false;
                saveAsFile.Enabled        = false;
                RegistryHelper.SaveHKLMRegistryString("ReportedExceptions", reportedExceptions + "," + newHashCode);
            }
        }
Exemple #29
0
        public bool SendReportViaEmail(ReportExceptionEventArgs reportExceptionEventArgs)
        {
            try
            {
                if (SendingReportViaEmailFeedback != null)
                {
                    SendingReportViaEmailFeedback(this, new SendingReportViaEmailFeedbackEventArgs(SendingReportViaEmailStep.PreparingReport));
                }

                // WARNING: To open the encrypted report with SA, the file must have a .saencryptedreport extension.
                string tempFileName = Path.GetTempPath() + Guid.NewGuid().ToString("N") + ".saencryptedreport";

                if (reportExceptionEventArgs.SaveEncryptedReport(tempFileName))
                {
                    if (SendingReportViaEmailFeedback != null)
                    {
                        SendingReportViaEmailFeedback(this, new SendingReportViaEmailFeedbackEventArgs(SendingReportViaEmailStep.Transfering));
                    }

                    bool transferingFailed = false;

                    try
                    {
                        SendEmail(tempFileName);
                    }
                    catch (Exception exception)
                    {
                        if (SendingReportViaEmailFeedback != null)
                        {
                            SendingReportViaEmailFeedback(this, new SendingReportViaEmailFeedbackEventArgs(SendingReportViaEmailStep.Transfering, exception.Message));
                        }
                        transferingFailed = true;
                    }

                    try
                    {
                        File.Delete(tempFileName);
                    }
                    catch
                    {
                    }

                    if (transferingFailed)
                    {
                        return(false);
                    }
                    else
                    {
                        if (SendingReportViaEmailFeedback != null)
                        {
                            SendingReportViaEmailFeedback(this, new SendingReportViaEmailFeedbackEventArgs(SendingReportViaEmailStep.Finished));
                        }
                        return(true);
                    }
                }
                else
                {
                    if (SendingReportViaEmailFeedback != null)
                    {
                        SendingReportViaEmailFeedback(this, new SendingReportViaEmailFeedbackEventArgs(SendingReportViaEmailStep.PreparingReport, "Cannot create temp file."));
                    }
                    return(false);
                }
            }
            catch (ThreadAbortException)
            {
                return(false);
            }
            catch (Exception fatalException)
            {
                MessageBox.Show(fatalException.ToString(), string.Format(Localization.FatalError, ApplicationName), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
        Tuple <string, bool> InternalHandler(Exception exception, ReportExceptionEventArgs et,
                                             bool loader = false)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }
            if (et == null)
            {
                throw new ArgumentNullException(nameof(et));
            }

            if (exception is ReportHandledException)
            {
                return(Tuple.Create((string)null, true));
            }

            if (exception.InnerException != null)
            {
                var r = InternalHandler(exception.InnerException, et, loader);
                if (r != null)
                {
                    return(r);
                }
            }

            var compositionException = exception as CompositionException;

            if (compositionException != null)
            {
                var r = HandleCompositionError(compositionException, et);
                if (r != null && r.Item1 != null)
                {
                    return(r);
                }
            }

            var aggregrateException = exception as AggregateException;

            if (aggregrateException != null)
            {
                var r = HandleAggregateException(aggregrateException, et);
                if (r != null && r.Item1 != null)
                {
                    return(r);
                }
            }

            var loaderException = exception as ReflectionTypeLoadException;

            if (loaderException != null)
            {
                var r = HandleReflectionTypeLoadException(loaderException, et);
                if (r != null && r.Item1 != null)
                {
                    return(r);
                }
            }

            // Corrupted system files: https://dev-heaven.net/issues/28675 and https://dev-heaven.net/issues/34551
            // Desktop Composition: http://dev-heaven.net/issues/26847
            // SyncFlush: http://dev-heaven.net/issues/26098
            if (exception is COMException)
            {
                if (exception.Message.Contains("HRESULT"))
                {
                    if (exception.Message.Contains(@"{56FDF344-FD6D-11D0-958A-006097C9A090}") ||
                        exception.StackTrace.Contains("ApplyTaskbarItemInfo"))
                    {
                        return(Tuple.Create(StrHresultTaskbar, false));
                    }
                    return(Tuple.Create(StrHresult, true));
                }

                return(Tuple.Create(StrInterop, true));
            }

            // HRESULT_FROM_WIN32(ERROR_NOT_FOUND)
            if (exception is XamlParseException)
            {
                if (exception.StackTrace != null &&
                    exception.StackTrace.Contains("Standard.NativeMethods.GetCurrentThemeName"))
                {
                    return(Tuple.Create(StrChrome, true));
                }
            }

            // Unable to Open configuration file: http://dev-heaven.net/issues/26856
            // Root Element Missing: http://dev-heaven.net/issues/21669
            // Not relevant for PwS
            //if (exception is ConfigurationErrorsException) {
            //return Tuple.Create(StrConfiguration, true);
            //}

            if (exception is TypeInitializationException)
            {
                // UIAutomationCore.dll: http://dev-heaven.net/issues/24462
                if (
                    exception.Message.IndexOf("System.Windows.Automation.InvokePatternIdentifiers",
                                              StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return(Tuple.Create(StrTypeInitUiAutomationCore, true));
                }
            }
            if (exception is DllNotFoundException)
            {
                // UIAutomationCore.dll: http://dev-heaven.net/issues/24462
                if (exception.Message.IndexOf("UIAutomationCore.dll", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return(Tuple.Create(StrTypeInitUiAutomationCore, true));
                }

                if (exception.Message.IndexOf(@"\Microsoft.NET\Framework\", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return(Tuple.Create(StrTypeInitFramework, true));
                }

                if (exception.Message.IndexOf(@"\Windows\", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    return(Tuple.Create(StrBadImageFormat, true));
                }
            }

            if (exception is NotImplementedException)
            {
                if (exception.StackTrace != null &&
                    exception.StackTrace.Contains("MS.Internal.AppModel.ITaskbarList.HrInit"))
                {
                    return(Tuple.Create(StrTbaritem, false));
                }
            }

            if (exception is BadImageFormatException)
            {
                return(Tuple.Create(StrBadImageFormat, true));
            }

            // More common errors, so try to catch them only in more specific situations
            // Retrieving the Com class ....: http://dev-heaven.net/issues/26851
            // But probably also when e.g System.Windows.Interactivity.dll is missing etc!!
            if (exception is FileNotFoundException)
            {
                if (loader ||
                    exception.Message.Contains("System.") ||
                    exception.Message.Contains("Microsoft.")

                    /*                    || exception.Message.Contains("System.Reactive.Linq,")
                    || exception.Message.Contains("System.Windows.Interactivity,")*/)
                {
                    return(Tuple.Create(StrFileNotFound, true));
                }
            }

            if (exception is FileLoadException)
            {
                return(Tuple.Create(exception.Message.Contains("'System.Core,") ? StrKB2468871 : StrCorrupt,
                                    true));
            }

            return(Tuple.Create((string)null, true));
        }
Exemple #31
0
 protected override void OnReportException(ReportExceptionEventArgs e) {
     //LogError(e.Exception);
     //TryAddFullExceptionTrace(e);
     TryAddSystemInfo(e);
 }
        Tuple<string, bool> InternalHandler(Exception exception, ReportExceptionEventArgs et,
            bool loader = false) {
            Contract.Requires<ArgumentNullException>(exception != null);
            Contract.Requires<ArgumentNullException>(et != null);

            if (exception is ReportHandledException)
                return Tuple.Create((string) null, true);

            if (exception.InnerException != null) {
                var r = InternalHandler(exception.InnerException, et, loader);
                if (r != null)
                    return r;
            }

            var compositionException = exception as CompositionException;
            if (compositionException != null) {
                var r = HandleCompositionError(compositionException, et);
                if (r != null && r.Item1 != null)
                    return r;
            }

            var aggregrateException = exception as AggregateException;
            if (aggregrateException != null) {
                var r = HandleAggregateException(aggregrateException, et);
                if (r != null && r.Item1 != null)
                    return r;
            }

            var loaderException = exception as ReflectionTypeLoadException;
            if (loaderException != null) {
                var r = HandleReflectionTypeLoadException(loaderException, et);
                if (r != null && r.Item1 != null)
                    return r;
            }

            // Corrupted system files: https://dev-heaven.net/issues/28675 and https://dev-heaven.net/issues/34551
            // Desktop Composition: http://dev-heaven.net/issues/26847
            // SyncFlush: http://dev-heaven.net/issues/26098
            if (exception is COMException) {
                if (exception.Message.Contains("HRESULT")) {
                    if (exception.Message.Contains(@"{56FDF344-FD6D-11D0-958A-006097C9A090}") ||
                        exception.StackTrace.Contains("ApplyTaskbarItemInfo"))
                        return Tuple.Create(StrHresultTaskbar, false);
                    return Tuple.Create(StrHresult, true);
                }

                return Tuple.Create(StrInterop, true);
            }

            // HRESULT_FROM_WIN32(ERROR_NOT_FOUND)
            if (exception is XamlParseException) {
                if (exception.StackTrace != null
                    && exception.StackTrace.Contains("Standard.NativeMethods.GetCurrentThemeName"))
                    return Tuple.Create(StrChrome, true);
            }

            // Unable to Open configuration file: http://dev-heaven.net/issues/26856
            // Root Element Missing: http://dev-heaven.net/issues/21669
            // Not relevant for PwS
            //if (exception is ConfigurationErrorsException) {
            //return Tuple.Create(StrConfiguration, true);
            //}

            if (exception is TypeInitializationException) {
                // UIAutomationCore.dll: http://dev-heaven.net/issues/24462
                if (
                    exception.Message.IndexOf("System.Windows.Automation.InvokePatternIdentifiers",
                        StringComparison.OrdinalIgnoreCase) >= 0)
                    return Tuple.Create(StrTypeInitUiAutomationCore, true);
            }
            if (exception is DllNotFoundException) {
                // UIAutomationCore.dll: http://dev-heaven.net/issues/24462
                if (exception.Message.IndexOf("UIAutomationCore.dll", StringComparison.OrdinalIgnoreCase) >= 0)
                    return Tuple.Create(StrTypeInitUiAutomationCore, true);

                if (exception.Message.IndexOf(@"\Microsoft.NET\Framework\", StringComparison.OrdinalIgnoreCase) >= 0)
                    return Tuple.Create(StrTypeInitFramework, true);

                if (exception.Message.IndexOf(@"\Windows\", StringComparison.OrdinalIgnoreCase) >= 0)
                    return Tuple.Create(StrBadImageFormat, true);
            }

            if (exception is NotImplementedException) {
                if (exception.StackTrace != null
                    && exception.StackTrace.Contains("MS.Internal.AppModel.ITaskbarList.HrInit"))
                    return Tuple.Create(StrTbaritem, false);
            }

            if (exception is BadImageFormatException)
                return Tuple.Create(StrBadImageFormat, true);

            // More common errors, so try to catch them only in more specific situations
            // Retrieving the Com class ....: http://dev-heaven.net/issues/26851
            // But probably also when e.g System.Windows.Interactivity.dll is missing etc!!
            if (exception is FileNotFoundException) {
                if (loader
                    || exception.Message.Contains("System.")
                    || exception.Message.Contains("Microsoft.")
                    /*                    || exception.Message.Contains("System.Reactive.Linq,")
                    || exception.Message.Contains("System.Windows.Interactivity,")*/)
                    return Tuple.Create(StrFileNotFound, true);
            }

            if (exception is FileLoadException) {
                return Tuple.Create(exception.Message.Contains("'System.Core,") ? StrKB2468871 : StrCorrupt,
                    true);
            }

            return Tuple.Create((string) null, true);
        }
Exemple #33
0
 static void TryAddFullExceptionTrace(ReportExceptionEventArgs e)
 {
     try {
         e.AddCustomProperty("Full exception trace", PrettyExceptions.FormatException(e.Exception));
     } catch {}
 }