一、在program.cs处完善成如下,但是这样后只能抛出主线程(UI)的错误,所以请看第二步

/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//全局异常捕捉
Application.ThreadException += Application_ThreadException; //UI线程异常
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //多线程异常

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}

//UI线程异常
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
WinformException.FrmBugReport.ShowBug(e.Exception);
}

//多线程异常
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
WinformException.FrmBugReport.ShowBug((Exception)e.ExceptionObject);
}

 
View Code

相关文章:

  • 2022-02-17
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-01-06
  • 2022-02-05
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案