WinForms全局异常处理?

WinForms全局异常处理?,第1张

WinForms全局异常处理?

如果

#26
是异常,则可以使用
AppDomain.CurrentDomain.UnhandledException
事件。如果这只是一个返回值,那么我看不到有任何全局处理该值的机会。

public static void Main(){    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);    // start main thread here}static void MyHandler(object sender, UnhandledExceptionEventArgs args) {    Exception e = (Exception) args.ExceptionObject;    Console.WriteLine("MyHandler caught : " + e.Message);}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4908284.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-12
下一篇2022-11-12

发表评论

登录后才能评论

评论列表(0条)

    保存