示例#1
1
        private static void HandleException(Exception exception)
        {
            

            //System.ComponentModel.CancelEventArgs e= new System.ComponentModel.CancelEventArgs();
            //e.Cancel = true;
            //Application.Exit(e);
          
            //Application.Exit();
            //Environment.Exit(0);

            if (SystemInformation.UserInteractive)
            {
                ShowMessageBox("UnhandledException", exception);
                
                //return;
                using (ThreadExceptionDialog dialog = new ThreadExceptionDialog(exception))
                {
                    if (dialog.ShowDialog() == DialogResult.Cancel)
                        return;
                }
                Application.Exit();
                Environment.Exit(0);
            }
        }
示例#2
0
        /// <summary>
        /// 显示异常详细信息
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DialogResult ShowException(Exception ex, string title = "错误")
        {
            var frm = new ThreadExceptionDialog(ex);

            frm.Text = title;
            return(frm.ShowDialog());
        }
示例#3
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Logger.Log(e.Exception.ToString());

            {
                if (!SystemInformation.UserInteractive)
                    return;

                DialogResult dialogResult;
                using (var threadExceptionDialog = new ThreadExceptionDialog(e.Exception))
                {
                    dialogResult = threadExceptionDialog.ShowDialog();
                }
                switch (dialogResult)
                {
                    case DialogResult.Abort:
                        Application.Exit();
                        Environment.Exit(0);
                        break;
                    case DialogResult.Yes:
                        var warningException = e.Exception as WarningException;
                        if (warningException == null)
                            break;
                        Help.ShowHelp(null, warningException.HelpUrl, warningException.HelpTopic);
                        break;
                }
            }
        }
示例#4
0
 static void OnThreadException(object sender, ThreadExceptionEventArgs args)
 {
     if (SystemInformation.UserInteractive) {
         using (ThreadExceptionDialog dialog = new ThreadExceptionDialog(args.Exception)) {
             if (dialog.ShowDialog() == DialogResult.Cancel)
                 return;
         }
         Application.Exit();
         Environment.Exit(0);
     }
 }
 private static void HandleThreadException(object sender, string caption, Exception ex)
 {
     try
     {
         ThreadExceptionDialog dlg = new ThreadExceptionDialog (ex);
         dlg.Text = caption;
         if (dlg.ShowDialog () == DialogResult.Abort)
         {
             Application.Exit ();
         }
     }
     catch {}
 }
示例#6
0
        public DialogRunner(System.ComponentModel.Component dialog)
        {
            commonDialog = dialog as SWF.CommonDialog;
            if (commonDialog == null)
            {
                threadExceptionDialog = dialog as SWF.ThreadExceptionDialog;
            }
            if (commonDialog == null && threadExceptionDialog == null)
            {
                throw new ArgumentException("Unsupported dialog type: " + dialog);
            }

            Show();
        }
示例#7
0
 protected override void OnSyncAction(SyncAction action, SyncStatus status)
 {
     if (action == this.UpdateCheckAction)
     {
         try
         {
             OnCheckForUpdate(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
 }
 private static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.DoEvents();
         Application.Run(new PlayForm());
     }
     catch (Exception err)
     {
         using (ThreadExceptionDialog errDlg = new ThreadExceptionDialog(err))
         {
             errDlg.ShowDialog();
         }
     }
 }
示例#9
0
        public static void OnThreadException(Exception t)
        {
            if (MWFThread.Current.HandlingException)
            {
                /* we're already handling an exception and we got
                 * another one?  print it out and exit, this means
                 * we've got a runtime/SWF bug. */
                Console.WriteLine(t);
                // Don't use Application.Exit here, since it may cause a stack overflow
                // in certain cases. It's however hard to reproduce since it seems to
                // be depending on when the GC kicks in.
                Environment.Exit(1);
            }

            try
            {
                MWFThread.Current.HandlingException = true;

                if (Application.ThreadException != null)
                {
                    Application.ThreadException(null, new ThreadExceptionEventArgs(t));
                    return;
                }

                if (SystemInformation.UserInteractive)
                {
                    Form form = new ThreadExceptionDialog(t);
                    form.ShowDialog();
                }
                else
                {
                    Console.WriteLine(t.ToString());
                    Application.Exit();
                }
            }
            finally
            {
                MWFThread.Current.HandlingException = false;
            }
        }
            internal void OnThreadException(Exception t)
            {
                if (!this.GetState(4))
                {
                    this.SetState(4, true);
                    try
                    {
                        WarningException exception;
                        if (this.threadExceptionHandler != null)
                        {
                            this.threadExceptionHandler(Thread.CurrentThread, new ThreadExceptionEventArgs(t));
                        }
                        else if (SystemInformation.UserInteractive)
                        {
                            ThreadExceptionDialog dialog = new ThreadExceptionDialog(t);
                            DialogResult oK = DialogResult.OK;
                            System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
                            try
                            {
                                oK = dialog.ShowDialog();
                            }
                            finally
                            {
                                CodeAccessPermission.RevertAssert();
                                dialog.Dispose();
                            }
                            switch (oK)
                            {
                                case DialogResult.Abort:
                                    Application.ExitInternal();
                                    new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
                                    Environment.Exit(0);
                                    break;

                                case DialogResult.Yes:
                                    goto Label_0086;
                            }
                        }
                        return;
                    Label_0086:
                        exception = t as WarningException;
                        if (exception != null)
                        {
                            Help.ShowHelp(null, exception.HelpUrl, exception.HelpTopic);
                        }
                    }
                    finally
                    {
                        this.SetState(4, false);
                    }
                }
            }
示例#11
0
 private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using(new HourGlass(this))
         {
             CheckForUpdates updateChecker = new CheckForUpdates();
             updateChecker.PadUrl = Program.PadUrl;
             updateChecker.PromptAlways = true;
             updateChecker.SendReport(null);
         }
     }
     catch (Exception ex)
     {
         ThreadExceptionDialog dlg = new ThreadExceptionDialog(ex);
         dlg.Text = "Error checking for new updates";
         dlg.ShowDialog(this);
     }
 }
示例#12
0
        private void GUI_FormClosing(object sender, FormClosingEventArgs e)
        {
            try {
                var sd = FuseboxFreedom.Properties.Settings.Default;
                sd.project = SaveSettingsXML().ToString();
                sd.recent = new StringCollection();
                sd.recent.AddRange(
                    btn_load.DropDownItems.Cast<ToolStripMenuItem>()
                            .Select(btn => btn.Text).ToArray()
                );
                sd.Save();
            } catch (Exception ex) {

                var dr = new ThreadExceptionDialog(ex).ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.Abort) {
                    e.Cancel = true;
                }
            }
        }
示例#13
0
        /// <summary>
        /// Called when an action is triggered for the node. Derived classes should override this method to provide application-specific handling of the action.
        /// </summary>
        /// <param name="action">The action that has been triggered.</param>
        /// <param name="status">The status object.</param>
        protected override void OnSyncAction(SyncAction action, SyncStatus status)
        {
            if (action == this.CreateNewCompany)
            {
                try
                {
                    OnCreateNewCompany(status);
                }
                catch (LicenseExpiredException)
                {
                    MessageBoxParameters msgBox = new MessageBoxParameters();
                    msgBox.Icon = MessageBoxIcon.Error;
                    msgBox.Caption = SnapInResources.License_Expired;
                    msgBox.Text = string.Format(SnapInResources.License_Expired_Text, Mediachase.Ibn.IbnConst.FullProductName);
                    msgBox.Buttons = MessageBoxButtons.OK;

                    this.SnapIn.Console.ShowDialog(msgBox);
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == this.CreateNewCompanyForDatabase)
            {
                try
                {
                    OnCreateNewCompanyForDatabase(status);
                }
                catch (LicenseExpiredException)
                {
                    MessageBoxParameters msgBox = new MessageBoxParameters();
                    msgBox.Icon = MessageBoxIcon.Error;
                    msgBox.Caption = SnapInResources.License_Expired;
                    msgBox.Text = string.Format(SnapInResources.License_Expired_Text, Mediachase.Ibn.IbnConst.FullProductName);
                    msgBox.Buttons = MessageBoxButtons.OK;

                    this.SnapIn.Console.ShowDialog(msgBox);
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
        }
 /// <summary>
 /// Returns an observable sequence wrapping the AutoSizeChanged event on the ThreadExceptionDialog instance.
 /// </summary>
 /// <param name="instance">The ThreadExceptionDialog instance to observe.</param>
 /// <returns>An observable sequence wrapping the AutoSizeChanged event on the ThreadExceptionDialog instance.</returns>
 public static IObservable <EventPattern <EventArgs> > AutoSizeChangedObservable(this ThreadExceptionDialog instance)
 {
     return(Observable.FromEventPattern <EventHandler, EventArgs>(
                handler => instance.AutoSizeChanged += handler,
                handler => instance.AutoSizeChanged -= handler));
 }
示例#15
0
		public static void OnThreadException (Exception t)
		{
			if (MWFThread.Current.HandlingException) {
				/* we're already handling an exception and we got
				   another one?  print it out and exit, this means
				   we've got a runtime/SWF bug. */
				Console.WriteLine (t);
				// Don't use Application.Exit here, since it may cause a stack overflow
				// in certain cases. It's however hard to reproduce since it seems to 
				// be depending on when the GC kicks in.
				Environment.Exit(1);
			}

			try {
				MWFThread.Current.HandlingException = true;

				if (Application.ThreadException != null) {
					Application.ThreadException(null, new ThreadExceptionEventArgs(t));
					return;
				}

				if (SystemInformation.UserInteractive) {
					Form form = new ThreadExceptionDialog (t);
					form.ShowDialog ();
				} else {
					Console.WriteLine (t.ToString ());
					Application.Exit ();
				}
			} finally {
				MWFThread.Current.HandlingException = false;
			}
		}
        private void execButton_Click(object sender, System.EventArgs e)
        {
            AppForm ().ClearExecutionModelTabs ();

            try
            {
                ICommand command = new ExecuteHsmCommand (_Model, this, _LastFileName);
                command.Execute ();
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception ("Model represented by " + _LastFileName + " could not be loaded for execution", ex);
                ThreadExceptionDialog dialog = new ThreadExceptionDialog (ex2);
                dialog.ShowDialog ();
            }
        }
示例#17
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Queue<ProfilerEvent> saved;
            Exception exc;
            lock (this)
            {
                saved = m_events;
                m_events = new Queue<ProfilerEvent>(10);
                exc = m_profilerexception;
                m_profilerexception = null;
            }
            if (null != exc)
            {
                using (ThreadExceptionDialog dlg = new ThreadExceptionDialog(exc))
                {
                    dlg.ShowDialog();
                }
            }
            lock (m_Cached)
            {
                while (0 != saved.Count)
                {
                    NewEventArrived(saved.Dequeue(), 0 == saved.Count);
                }
                if (m_Cached.Count > m_currentsettings.Filters.MaximumEventCount)
                {
                    while (m_Cached.Count > m_currentsettings.Filters.MaximumEventCount)
                    {
                        m_Cached.RemoveAt(0);
                    }
                    lvEvents.VirtualListSize = m_Cached.Count;
                    lvEvents.Invalidate();
                }

                if ((null == m_prev) || (DateTime.Now.Subtract(m_prev.m_date).TotalSeconds >= 1))
                {
                    PerfInfo curr = new PerfInfo { m_count = m_EventCount };
                    if (m_perf.Count >= 60)
                    {
                        m_first = m_perf.Dequeue();
                    }
                    if (null == m_first) m_first = curr;
                    if (null == m_prev) m_prev = curr;

                    DateTime now = DateTime.Now;
                    double d1 = now.Subtract(m_prev.m_date).TotalSeconds;
                    double d2 = now.Subtract(m_first.m_date).TotalSeconds;
                    slEPS.Text = String.Format("{0} / {1} EPS(last/avg for {2} second(s))",
                        (Math.Abs(d1 - 0) > 0.001 ? ((curr.m_count - m_prev.m_count) / d1).ToString("#,0.00") : ""),
                                 (Math.Abs(d2 - 0) > 0.001 ? ((curr.m_count - m_first.m_count) / d2).ToString("#,0.00") : ""), d2.ToString("0"));

                    m_perf.Enqueue(curr);
                    m_prev = curr;
                }

            }
        }
示例#18
0
        /// <summary>
        /// Handles the execution of a selection-independent (view-global) action that runs synchronous to MMC.
        /// </summary>
        /// <param name="action">The executed action.</param>
        /// <param name="status">The object that holds the status information.</param>
        protected override void OnSyncAction(SyncAction action, SyncStatus status)
        {
            base.OnSyncAction(action, status);

            if (action == this.EditSqlServerSettingsAction)
            {
                try
                {
                    OnEditSqlServerSettingsAction(status);
                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == this.CreateAspAction)
            {
                try
                {
                    CreateAspSite(this.GetConfigurator(), this.SnapIn.Console, status);

                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == this.DeleteAspAction)
            {
                try
                {
                    OnDeleteAspAction(status);
                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == UpdateCommonComponentsAction)
            {
                try
                {
                    OnUpdateCommonComponentsAction(status);
                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == UpdateServerAction)
            {
                try
                {
                    OnUpdateServerAction(status);
                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
            else if (action == UpdateCheckAction)
            {
                try
                {
                    OnUpdateCheckAction(status);
                    this.ServerFeaturesControl.ReloadData();
                }
                catch (Exception ex)
                {
                    ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
                    this.SnapIn.Console.ShowDialog(exForm);
                }
            }
        }
示例#19
0
 /// <summary>
 /// Called when an action is triggered for the node. Derived classes should override this method to provide application-specific handling of the action.
 /// </summary>
 /// <param name="action">The action that has been triggered.</param>
 /// <param name="status">The status object.</param>
 protected override void OnSyncAction(SyncAction action, SyncStatus status)
 {
     if (action == this.StartAction)
     {
         try
         {
             OmStartCompany(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == this.StopAction)
     {
         try
         {
             OnStopCompany(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == this.ChangeDomainAction)
     {
         try
         {
             OnChangeDomain(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == this.UpgradeAction)
     {
         try
         {
             OnUpgrade(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == this.BrowseAction)
     {
         try
         {
             OnBrowse(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == EnableSchedulerServiceAction)
     {
         try
         {
             OnEnableSchedulerService(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == DisableSchedulerServiceAction)
     {
         try
         {
             OnDisableSchedulerService(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
     else if (action == ChangePortalPool)
     {
         try
         {
             OnChangePortalPool(status);
         }
         catch (Exception ex)
         {
             ThreadExceptionDialog exForm = new ThreadExceptionDialog(ex);
             this.SnapIn.Console.ShowDialog(exForm);
         }
     }
 }
示例#20
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _progress.Close();
            _progress = null;

            if (e.Error != null)
            {
                ThreadExceptionDialog ted = new ThreadExceptionDialog(e.Error);
                ted.ShowDialog();
            }
            else
            {
                SetStatus(_eltl.HighestLoggedLevel);

                _ac = (AssemblyComparison)e.Result;

                if (_ac != null)
                {
                    ApplyFilter();
                }
            }
        }
示例#21
0
            /// <include file='doc\Application.uex' path='docs/doc[@for="Application.ThreadContext.OnThreadException"]/*' />
            /// <devdoc>
            ///     Called when an untrapped exception occurs in a thread.  This allows the
            ///     programmer to trap these, and, if left untrapped, throws a standard error
            ///     dialog.
            /// </devdoc>
            /// <internalonly/>
            internal void OnThreadException(Exception t) {
                if (GetState(STATE_INTHREADEXCEPTION)) return;

                SetState(STATE_INTHREADEXCEPTION, true);
                try {
                    if (threadExceptionHandler != null) {
                        threadExceptionHandler(Thread.CurrentThread, new ThreadExceptionEventArgs(t));
                    }
                    else {
                        if (SystemInformation.UserInteractive) {
                            ThreadExceptionDialog td = new ThreadExceptionDialog(t);
                            DialogResult result = DialogResult.OK;

                            // SECREVIEW : This Assert is ok, this dialog shows up when the application is about to die. 
                            //             ShowDialog will generate a call to ContainerControl.SetActiveControl which demands 
                            //             ModifyFocus permission, need to assert it here.
                            //
                            IntSecurity.ModifyFocus.Assert();
                            try {
                                result = td.ShowDialog();
                            }
                            finally {
                                CodeAccessPermission.RevertAssert();
                                td.Dispose();
                            }
                            switch (result) {
                                case DialogResult.Abort:
                                    // SECREVIEW : The user clicked "Quit" in response to a exception dialog.
                                    //           : We only show the quit option when we own the message pump,
                                    //           : so this won't ever tear down IE or any other ActiveX host.
                                    //           :
                                    //           : This has a potential problem where a component could
                                    //           : cause a failure, then try a "trick" the user into hitting
                                    //           : quit. However, no component or application outside of
                                    //           : the windows forms assembly can modify the dialog, so this is
                                    //           : a really minor concern.
                                    //
                                    Application.ExitInternal();

                                    // SECREVIEW : We can't revert this assert... after Exit(0) is called, no
                                    //           : more code is executed...
                                    //
                                    new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
                                    Environment.Exit(0);
                                    break;
                                case DialogResult.Yes:
                                    WarningException w = t as WarningException;
                                    if (w != null) {
                                        Help.ShowHelp(null, w.HelpUrl, w.HelpTopic);
                                    }
                                    break;
                            }
                        }
                        else {
                            // Ignore unhandled thread exceptions. The user can
                            // override if they really care.
                            //
                        }

                    }
                }
                finally {
                    SetState(STATE_INTHREADEXCEPTION, false);
                }
            }
示例#22
0
		public DialogRunner (System.ComponentModel.Component dialog)
		{
			commonDialog = dialog as SWF.CommonDialog;
			if (commonDialog == null)
				threadExceptionDialog = dialog as SWF.ThreadExceptionDialog;
			if (commonDialog == null && threadExceptionDialog == null)
				throw new ArgumentException ("Unsupported dialog type: " + dialog);

			Show ();
		}