Example #1
0
 private static void ShowErrorReport(object sender, SendExceptionClickEventArgs args)
 {
     using (ShowException showException = new ShowException(CreateException(args.UnhandledException)))
     {
         showException.ShowDialog();
     }
 }
Example #2
0
        private static void SendException(object sender, SendExceptionClickEventArgs args)
        {
            // Send the exception to the server
            try
            {
                new ExceptionSender(CreateException(args.UnhandledException)).Send();

                if (!args.RestartApp)
                {
                    return;
                }

                Process.Start(Application.ExecutablePath);
                Application.Exit();
            }
            catch
            {
                // Yes, catch everything
            }
        }
Example #3
0
        /// <summary>
        /// Raise Exception Dialog box for both UI and non-UI Unhandled Exceptions
        /// </summary>
        /// <param name="e">Catched exception</param>
        private void ShowUnhandledExceptionDlg(Exception e)
        {
            Exception unhandledException = e;

            if (unhandledException == null)
            {
                unhandledException = new Exception("Unknown unhandled exception occurred!");
            }

            UnhandledExDlgForm exDlgForm = new UnhandledExDlgForm();

            try
            {
                string appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
                exDlgForm.Text            = appName;
                exDlgForm.labelTitle.Text = String.Format(exDlgForm.labelTitle.Text, appName);

                // Do not show link label if OnShowErrorReport is not handled
                exDlgForm.labelLinkTitle.Visible = (OnShowErrorReportClick != null);
                exDlgForm.linkLabelData.Visible  = (OnShowErrorReportClick != null);

                // Disable the Button if OnSendExceptionClick event is not handled
                exDlgForm.buttonSend.Enabled = (OnSendExceptionClick != null);

                // Disable the Button if OnCopyToClipboardClick event is not handled
                exDlgForm.buttonCopy.Enabled = (OnCopyToClipboardClick != null);

                // Handle clicks on report link label
                exDlgForm.linkLabelData.LinkClicked += delegate(object o, LinkLabelLinkClickedEventArgs ev)
                {
                    if (OnShowErrorReportClick != null)
                    {
                        SendExceptionClickEventArgs ar = new SendExceptionClickEventArgs((bool)true, unhandledException);
                        OnShowErrorReportClick(this, ar);
                    }
                };

                exDlgForm.buttonCopy.Click += delegate(object o, EventArgs ev)
                {
                    if (OnCopyToClipboardClick != null)
                    {
                        SendExceptionClickEventArgs ar = new SendExceptionClickEventArgs((bool)true, unhandledException);
                        OnCopyToClipboardClick(this, ar);
                    }
                    exDlgForm.buttonCopy.Enabled = false;
                };

                // Show the Dialog box:
                bool sendDetails = (exDlgForm.ShowDialog() == System.Windows.Forms.DialogResult.Yes);

                if (OnSendExceptionClick != null)
                {
                    SendExceptionClickEventArgs ar = new SendExceptionClickEventArgs(sendDetails, unhandledException);
                    OnSendExceptionClick(this, ar);
                }
            }
            finally
            {
                exDlgForm.Dispose();
            }
        }