C# winform捕获程序异常内容

static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.ThreadException += Application_ThreadException;
    Application.Run(new Form1());
}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
    MessageBox.Show(e.Exception.ToString());
}

 

posted @ 2023-11-04 23:31  芈璐  阅读(44)  评论(0编辑  收藏  举报