MySqlConnection.Open()处 捕获不到吗?
如果是新开线程去连接,异常需要在线程执行的方法中try catch.
或者 处理全局的异常
winform
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += new ThreadExceptionEventHandler(Service_UIThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
webapp
Global.asax
protected void Application_Error(object sender, EventArgs e) { }中处理
如果是新开线程去连接,异常需要在线程执行的方法中try catch.
或者 处理全局的异常
winform
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += new ThreadExceptionEventHandler(Service_UIThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
webapp
Global.asax
protected void Application_Error(object sender, EventArgs e) { }中处理