简体   繁体   English

处理AppDomain.CurrentDomain.UnhandledException中的异常

[英]Handle exceptions in AppDomain.CurrentDomain.UnhandledException

Is it possible to handle exceptions on the AppDomain.CurrentDomain.UnhandledException callback? 是否可以在AppDomain.CurrentDomain.UnhandledException回调上处理异常? I want to do the following: 我想做以下事情:

  • Show my own "an exception has occured" dialog, with a "Send Report" button 显示我自己的“发生异常”对话框,带有“发送报告”按钮
  • After the user dismissed the box, I want to close my app, but I do not want to Windows default crash dialog "The application needs to close" box to show up. 用户解雇后,我想关闭我的应用程序,但我不希望Windows默认崩溃对话框“应用程序需要关闭”框出现。

Can this be done? 可以这样做吗?

You could to use Application.SetUnhandledExceptionMode method. 您可以使用Application.SetUnhandledExceptionMode方法。

Please, take also a look here: User Friendly Exception Handling . 请看这里: 用户友好的异常处理

Hope this link helps: 希望此链接有助于:

http://www.switchonthecode.com/tutorials/csharp-tutorial-dealing-with-unhandled-exceptions http://www.switchonthecode.com/tutorials/csharp-tutorial-dealing-with-unhandled-exceptions

As the code shows, just listen to the exception and do what you want when it happens. 如代码所示,只需听取异常并在发生时执行您想要的操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AppDomain.CurrentDomain.UnhandledException不起作用 - AppDomain.CurrentDomain.UnhandledException Not working 不会调用AppDomain.CurrentDomain.UnhandledException - AppDomain.CurrentDomain.UnhandledException does not get called Revit Addin中的AppDomain.CurrentDomain.UnhandledException - AppDomain.CurrentDomain.UnhandledException in Revit Addin 在Windows服务中处理AppDomain.CurrentDomain.UnhandledException - Handling AppDomain.CurrentDomain.UnhandledException in windows service 为什么AppDomain.CurrentDomain.UnhandledException无法捕获非UI线程的未处理异常? - Why is the AppDomain.CurrentDomain.UnhandledException not catching unhandled exceptions from non-UI threads? Application.ThreadException 和 AppDomain.CurrentDomain.UnhandledException 都不受尊重 - Neither Application.ThreadException nor AppDomain.CurrentDomain.UnhandledException are respected 我可以在 class 库中向 AppDomain.CurrentDomain.UnhandledException 添加处理程序吗 - Can I Add a handler to AppDomain.CurrentDomain.UnhandledException in a class library 抑制 Application.ThreadException 和 AppDomain.CurrentDomain.UnhandledException - Suppressing Application.ThreadException and AppDomain.CurrentDomain.UnhandledException 处理AppDomain.CurrentDomain.UnhandledException时是否无法显示表单? - Is it impossible to show forms when handling a AppDomain.CurrentDomain.UnhandledException? AppDomain.CurrentDomain.UnhandledException不允许我完成功能 - AppDomain.CurrentDomain.UnhandledException does not let me finish my function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM