确定哪个代码行抛出异常 [英] Determining which code line threw the exception
本文介绍了确定哪个代码行抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在dotNet中,一行引发异常并被捕获,我如何知道哪个文件抛出异常?似乎比较简单,但是我无法理解...
In dotNet a line throws an exception and is caught, how can I figure out which line in which file threw the exception? Seems relatively straightforward, but I can't figure it out...
推荐答案
只有在调试符号可用。
catch(Exception ex) {
// check the ex.StackTrace property
}
如果要调试VS中的这种情况,最好只要查看
复选框
通用语言运行时异常
在异常
对话框位于调试
菜单。即使在尝试
块中,调试器也会立即中断。
If you want to debug such a situation in VS, you'd better just check Thrown
checkbox for Common Language Runtime Exceptions
in Exceptions
dialog located in Debug
menu. The debugger will break as soon as the exception is thrown, even if it's in a try
block.
这篇关于确定哪个代码行抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文