设置所有程序的异常处理执行程序

huangapple go评论50阅读模式
英文:

How set exeption executor for all program

问题

需要为所有我的WinForms程序设置catch(Exception ex){}

我尝试在try块中放置一个启动应用程序的函数,但只返回发生在此函数中的错误。是否有一种方法可以为整个程序设置catch(Exception ex),而不仅仅是一个函数。

我尝试使用AppDomain.CurrentDomain.UnhandledException,但这不起作用。

对不起,我的英文不太好。

英文:

I need to set catch(Exeption ex){} for all my program on winforms.

I tried to put a function in try that launches the application, but only errors that occurred in this function are returned. Is there any way to set catch(Exception ex) for the whole program and not for 1 function.
I tried use AppDomain.CurrentDomain.UnhandledException but this is not work.
Sorry for my bad English

答案1

得分: 1

在WinForms中,异常不应影响UI事件循环。您需要根据每个事件处理程序使用catch语句。没有全局处理程序。

英文:

In winforms, exceptions must not hit the UI event loop. You need to catch on a per event-handler basis. There is no global handler.

huangapple
  • 本文由 发表于 2023年2月23日 20:12:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544666.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定