zoukankan      html  css  js  c++  java
  • winform 捕获并处理未处理的异常

        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(AppThreadException);
                Application.Run(new sqlToXMLtool());
            }

            private static void AppThreadException(object source, System.Threading.ThreadExceptionEventArgs e)
            {
                string errorMsg = string.Format("未处理异常: \n{0}\n", e.Exception.Message);
                errorMsg += Environment.NewLine;

                DialogResult result = MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);

                //如果点击“中止”则退出程序
                if (result == DialogResult.Abort)
                {
                    Application.Exit();
                }
            }
        }

  • 相关阅读:
    [转]开发者最容易犯的13个JavaScript错误
    http状态码表
    RDLC报表部署到服务器的相关问题
    sharepoint权限集中管理工具
    依赖注入
    HttpModule & HttpHandle
    回滚事务
    HTTPMOUDLE 和httphandler 学习
    JavaScript操作Table
    .ne工具库
  • 原文地址:https://www.cnblogs.com/wangjingblogs/p/9527_wangjing.html
Copyright © 2011-2022 走看看