如何在抛出 catch 之前在 try 语句中设置断点?

How to set a breakpoint in a try statement before the catch is thrown?

尝试调试一个 try catch,该 try catch 在其中一次迭代中弹出错误之前被迭代了很多次。除了在 try catch 和垃圾邮件 f10 的开头设置断点之外,还有其他方法吗?由于多种原因,这是有问题的...

我想我可以做一个计数并显示失败的迭代,但这看起来太过分了。有什么可以帮助我的吗?

P.S。我在 VS2015 输入

Is there a way other then setting a breakpoint at the beginning of the try catch and spamming f10?

是的,这就是所谓的条件断点。放置一个断点,然后将鼠标放在断点上。单击设置图标和 select condition 复选框并提供您的条件(例如,当迭代变为 10 时)。只有当条件满足或者条件变为true

时才会中断

如果您了解触发异常的状态,您可以使用条件断点。

https://blogs.msdn.microsoft.com/visualstudioalm/2014/10/06/new-breakpoint-configuration-experience-in-visual-studio-2015/