本文介绍了获得第一次机会异常的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我收到从什么地方抛出的异常,但我从编译器得到的是类型System.ArgumentOutOfRangeExceptionmscorlib.dll中发生的第一个机会异常。这是相当对我没用,因为这不是我的代码(很肯定它的默认库)。我希望看到一个堆栈跟踪或东西,所以我知道在我的代码的东西出了问题。这是一个相当大的代码库(其中大部分是不是我的),并且有很多的多线程和其他的东西去的,所以它几乎是不可能的尝试,并通过代码,而无需从哪里开始寻找一些想法一步。有一些设置的地方,使所有异常引发休息,所以我可以看到调用堆栈发生时,而不是仅仅让他们静静地失败,并在输出? 一个完全无用的错误信息解决方案 您有几个选项。首先,像格雷格说,你可能会导致VS破裂发生任何异常时: 确认这些被选中,然后单击确定: 这会导致Visual Studio中打破地方发生异常。 另一种方法是捕获异常,要么只要写堆栈跟踪,或写异常(使用的ToString())来输出窗口: 然后检查你的输出窗口: I'm getting exceptions thrown from somewhere, but all I get from the compiler is "A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll". This is fairly useless to me, as that's not my code (pretty sure it's default library). I'd like to see a stack-trace or something so I know where in my code things went wrong. It's a fairly large codebase (much of which is not mine), and there's a lot of multi-threading and other stuff going on, so it's nearly impossible to try and step through the code without some idea of where to start looking. Is there some setting somewhere to make ALL exceptions trigger a break so I can see the call-stack when they occur, rather than just having them silently fail with a completely useless error message in the output? 解决方案 You have a couple of options. First, like Greg said, you can cause VS to break when any exception occurs:Make sure these are checked, then click OK:That will cause Visual Studio to break wherever the exception occurs.Another approach is to catch the exception and either write just the stack trace, or write the exception (using ToString()) to the output window:Then check your output window: 这篇关于获得第一次机会异常的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 23:19