取以下函数:
DataTable go() {
return someTableAdapter.getSomeData();
}
当我在这个函数中设置断点时,是否有可能检查返回值?Go()直接耦合到.aspx页面中的数据网格。
检查返回数据表的唯一方法是使用临时变量。然而,这有点不方便。没有别的办法了吗?
取以下函数:
DataTable go() {
return someTableAdapter.getSomeData();
}
当我在这个函数中设置断点时,是否有可能检查返回值?Go()直接耦合到.aspx页面中的数据网格。
检查返回数据表的唯一方法是使用临时变量。然而,这有点不方便。没有别的办法了吗?
当前回答
前。net时代的老把戏:打开寄存器窗口并查看EAX寄存器的值。它包含最后调用的函数的返回值。
其他回答
根据客户反馈网站,这可以在Visual Studio 2013中使用CLR 4.5.1完成。它在以前的c#版本中不可用。
(Visual Studio 2008和更早的版本支持VB.NET。C/ c++开发人员一直可以使用它。)
将返回表达式拖放到观察窗口中。
例如,在语句中
return someTableAdapter.getSomeData();
拖放
someTableAdapter.getSomeData()
进入一个观察窗口,你会看到数值。
你可以对任何表达式这样做。
根据微软的说法,没有办法用托管代码可靠地实现这一点。这是他们意识到并正在努力解决的问题:
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
是的,有一个很好的方法。一个显著的缺点是你必须等待5年,也许6年。自从我看到你在2008年11月发的帖子,我建议你waaaaaa…
……aaaait。瞧!只是为了你,微软发布了最新的Visual Studio 2013,它是在调试模式下运行时从菜单中访问的默认功能(菜单debug→Windows→Autos)。
我知道的唯一方法是在返回行上放置一个断点,然后调用Quick Watch窗口并输入返回的表达式:
someTableAdapter.getSomeData();
但这只有在调用不改变任何对象的状态时才有效(因为当您恢复执行时,将会对同一方法进行第二次调用)。