取以下函数:
DataTable go() {
return someTableAdapter.getSomeData();
}
当我在这个函数中设置断点时,是否有可能检查返回值?Go()直接耦合到.aspx页面中的数据网格。
检查返回数据表的唯一方法是使用临时变量。然而,这有点不方便。没有别的办法了吗?
取以下函数:
DataTable go() {
return someTableAdapter.getSomeData();
}
当我在这个函数中设置断点时,是否有可能检查返回值?Go()直接耦合到.aspx页面中的数据网格。
检查返回数据表的唯一方法是使用临时变量。然而,这有点不方便。没有别的办法了吗?
当前回答
根据微软的说法,没有办法用托管代码可靠地实现这一点。这是他们意识到并正在努力解决的问题:
For those out there who have experience debugging native C++ or VB6 code, you may have used a feature where function return values are provided for you in the Autos window. Unfortunately, this functionality does not exist for managed code. While you can work around this issue by assigning the return values to a local variable, this is not as convenient because it requires modifying your code. In managed code, it’s a lot trickier to determine what the return value of a function you’ve stepped over. We realized that we couldn’t do the right thing consistently here and so we removed the feature rather than give you incorrect results in the debugger. However, we want to bring this back for you and our CLR and Debugger teams are looking at a number potential solutions to this problem. Unfortunately this is will not be part of Visual Studio 11.
https://connect.microsoft.com/VisualStudio/feedback/details/597933/add-a-return-pseudo-variable-to-the-visual-studio-debugger-for-net-code
其他回答
我同意这是一件非常有用的事情:不仅可以在退出方法之前看到它的返回值,而且还可以看到我刚刚跳过的方法的返回值。我把它作为Visual Studio商业扩展“OzCode”的一部分来实现。
有了它,你可以直接在代码编辑器中查看方法的返回值,就像一种hud显示:
要了解更多信息,请观看这个视频。
前。net时代的老把戏:打开寄存器窗口并查看EAX寄存器的值。它包含最后调用的函数的返回值。
使用Shift-F11走出go()方法,然后在“Autos”调试窗口中,它将显示方法调用的返回值,该方法调用刚刚弹出堆栈(在这种情况下,go()方法是你想要的)。这是Visual Studio 2005中的行为;我还没有使用Visual Studio 2008,所以我不知道这个行为是否在那个版本相同。
我认为您可以通过查看寄存器窗口(调试/ Windows /寄存器)中的RAX寄存器来确定这一点。退出函数(SHIFT + F11)后,检查RAX寄存器。我不知道事实,但你可以检查一个寄存器(在。net时代之前)并看到那里的返回值。它甚至可能是RAX和RBX的组合,等等。
您可以尝试选择“someTableAdapter.getSomeData();”,右键单击它,然后选择快速观察。