C# Try/Catch 不捕获异常 [英] C# Try/Catch doesn't catch exception

查看:100
本文介绍了C# Try/Catch 不捕获异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了 try catch 块的问题.它不会捕获 try 块中代码的异常.有没有人已经遇到过这样的问题并且知道如何解决它.变量 myCon 是一个 MySqlConnection.超出会话的wait_timeout 时发生异常.重新启动、重建、更改 CPU 设置已经尝试过.

I got an issue with a try catch block. It doesn't catch the exception of the code in the try block. Does anybody already had an issue like that and know how to solve it. The variable myCon is a MySqlConnection. The Exception occurs when the wait_timeout of the session is exceeded. Restarting, Rebuilt, change of CPU settings already tried.

附言当我按 F10/F5 时,它不会跳入 catch 块

P.S. When I press F10/F5 it doesn't jump into the catch block

推荐答案

我不确定,但我看不出 Ping() 实际上让异常通过.它只返回真或假.

I am not sure, but I can't see that Ping() is actually letting exceptions pass through. It just returns true or false.

例如,Open() 方法实际上可能会抛出 MySqlException 类型的异常,但不会抛出 Ping()

For example the Open() method actually might throw an exception of type MySqlException, but not Ping()

这篇关于C# Try/Catch 不捕获异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆