有没有一种方法(除了WerAddExcludedApplication不能在Windows XP中工作)来禁用窗口“应用程序遇到问题,需要closures”,从我的应用程序崩溃时出现?
替代文字http://img.zgserver.com/windows/2vvw6yd.png
我需要这个在Windows XP中工作。
重命名和复制程序集是否安全?
将.NETconfiguration为在Windows 8上使用3.5,在Windows 8上使用4.5
在Windows 8中检测重启 – 未调用SessionEnding
在Windows应用程序中是否有任何基于SSRS的商业产品可以提供更丰富的用户体验?
告诉Process.Start等待,直到前一个实例完成
检测Windows重新启动是否由于Windows更新
点击文本字段时,自动启动Windows Tablet中的键盘
在.NET中编写虚拟打印机
Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionFunction); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionFunction);
以下是来自MSDN的完整示例:
Thread newThread = null; // Starts the application. [SecurityPermission(SecurityAction.Demand,Flags = SecurityPermissionFlag.ControlAppDomain)] public static void Main(string[] args) { // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new ThreadExceptionEventHandler(ErrorHandlerForm.Form1_UIThreadException); // Set the unhandled exception mode to force all Windows Forms errors to go through // our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // Runs the application. Application.Run(new ErrorHandlerForm()); } // Programs the button to throw an exception when clicked. private void button1_Click(object sender,System.EventArgs e) { throw new ArgumentException("The parameter was invalid"); } // Start a new thread,separate from Windows Forms,that will throw an exception. private void button2_Click(object sender,System.EventArgs e) { ThreadStart newThreadStart = new ThreadStart(newThread_Execute); newThread = new Thread(newThreadStart); newThread.Start(); } // The thread we start up to demonstrate non-UI exception handling. void newThread_Execute() { throw new Exception("The method or operation is not implemented."); } // Handle the UI exceptions by showing a dialog Box,and asking the user whether // or not they wish to abort execution. private static void Form1_UIThreadException(object sender,ThreadExceptionEventArgs t) { DialogResult result = DialogResult.Cancel; try { result = ShowThreadExceptionDialog("Windows Forms Error",t.Exception); } catch { try { MessageBox.Show("Fatal Windows Forms Error","Fatal Windows Forms Error",MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Stop); } finally { Application.Exit(); } } // Exits the program when the user clicks Abort. if (result == DialogResult.Abort) Application.Exit(); } // Handle the UI exceptions by showing a dialog Box,and asking the user whether // or not they wish to abort execution. // NOTE: This exception cannot be kept from terminating the application - it can only // log the event,and inform the user about it. private static void CurrentDomain_UnhandledException(object sender,UnhandledExceptionEventArgs e) { try { Exception ex = (Exception)e.ExceptionObject; string errorMsg = "An application error occurred. Please contact the adminstrator " + "with the following @R_551_4045@ion:nn"; // Since we can't prevent the app from terminating,log this to the event log. if (!EventLog.sourceExists("ThreadException")) { EventLog.CreateEventSource("ThreadException","Application"); } // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.source = "ThreadException"; myLog.WriteEntry(errorMsg + ex.Message + "nnStack Trace:n" + ex.StackTrace); } catch (Exception exc) { try { MessageBox.Show("Fatal Non-UI Error","Fatal Non-UI Error. Could not write the error to the event log. Reason: " + exc.Message,MessageBoxButtons.OK,MessageBoxIcon.Stop); } finally { Application.Exit(); } } } // Creates the error message and displays it. private static DialogResult ShowThreadExceptionDialog(string title,Exception e) { string errorMsg = "An application error occurred. Please contact the adminstrator " + "with the following @R_551_4045@ion:nn"; errorMsg = errorMsg + e.Message + "nnStack Trace:n" + e.StackTrace; return MessageBox.Show(errorMsg,title,MessageBoxIcon.Stop); }
我的建议是,不要禁用此对话框,而要向Microsoft注册,以便您可以看到我们捕获的错误报告! 这样,你可以把这个对话框使用,而不是试图压制它。
http://msdn.microsoft.com/en-us/isv/bb190483.aspx
您需要处理Application.ThreadException和AppDomain.CurrentDomain.UnhandledException事件。
这不是一个程序化的解决方案,但你可以通过编辑Windows错误报告设置来做到这一点。
打开控制面板
打开系统,系统属性对话框将打开
转到高级选项卡
如果你想在一个应用程序上禁用它,点击选择程序按钮,将会打开一个对话框
单击(第二个)添加按钮将您的应用程序添加到“不要报告这些程序的错误”列表。
确认所有三个对话框…
没有未处理的异常。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。