예제 #1
0
        internal static void UnhandledException(Exception ex)
        {
            if (!busyException)
            {
                try
                {
                    busyException = true;

#if !DEBUG
                    try
                    {
#endif
                    InteropHelper.OutputDebugString(ex.Message);

                    BroadcastShutdownMessage();
                    string message = string.Empty;

                    ErrorHandleDialog ehd = new ErrorHandleDialog();
                    try
                    {
                        if (ex is HookException)
                        {
                            ehd.ErrorText.Text = SR.KrentoHookMissing;
                        }
                        else
                        {
                            while (ex.InnerException != null)
                            {
                                message = message + ex.Message + Environment.NewLine;
                                ex      = ex.InnerException;
                            }
                            message = message + ex.Message + Environment.NewLine;

                            StackTrace st = new StackTrace(ex);
                            message            = message + "Call stack:";
                            ehd.ErrorText.Text = message + Environment.NewLine + st.ToString();
                            InteropHelper.OutputDebugString(ehd.ErrorText.Text);
                        }

                        DialogResult ok = DialogResult.Cancel;

                        ThreadWindows threadWindows;
                        threadWindows = DisableTaskWindows();
                        try
                        {
                            ok = ehd.ShowDialog(MainForm);
                        }
                        finally
                        {
                            EnableTaskWindows(threadWindows);
                        }
                        if (ok == DialogResult.OK)
                        {
#if DEBUG
                            if (Debugger.IsAttached)
                            {
                                throw ex;
                            }
                            else
                            {
                                Killer.KillSelf();
                            }
#else
                            Killer.KillSelf();
#endif
                        }
                        else
                        {
#if DEBUG
                            if (Debugger.IsAttached)
                            {
                                throw ex;
                            }
                            else
                            {
                                Killer.KillSelf();
                            }
#else
                            Application.Restart();
                            Killer.KillSelf();
#endif
                        }
                    }
                    finally
                    {
                        ehd.Dispose();
                    }
#if !DEBUG
                }

                catch
                {
                    //Exception happens in exception handler
                    //Can't do anything now
                    TraceDebug.Trace(ex.Message);
                    MessageBox.Show(ex.ToString());
                    Killer.KillSelf();
                }
            }
#endif
                }
예제 #2
0
 void IContextManager.KillKrento()
 {
     Killer.KillSelf();
 }