在 Visual Studio 2008 中单步执行 C# 时如何找到方法调用方?

发布于 2024-07-30 10:37:07 字数 61 浏览 2 评论 0原文

如果我在方法上设置断点,当在 Visual Studio 2008 中命中断点时,如何查看调用该方法的内容?

If I set a breakpoint on a method, how can I see what called the method, when the breakpoint is hit in Visual Studio 2008?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

深海不蓝 2024-08-06 10:37:07

检查“调用堆栈”窗口(从菜单:“调试”>“窗口”>“调用堆栈”)。 双击每个条目将转到调用语句。 您还可以右键单击它以启用/禁用显示外部代码项和来自其他线程的调用。

Check the Call Stack window (from the menu: Debug > Windows > Call Stack). Double clicking each entry there will take you to the calling statement. You can also right click on it to enable/disable showing external code items and calls from other threads.

微暖i 2024-08-06 10:37:07

当断点被击中时,您可以查看整个调用堆栈。 您可以通过“调试”菜单 ->“Windows”->“调用堆栈”来打开该窗口。

您还可以通过快捷键 Alt+Ctrl+C

编辑来调出它:
您还可以右键单击函数名称,然后查看“调用者图表”,它将显示您的方法的所有调用者。 或者,您可以打开调用浏览器(通过查看 -> 其他窗口 -> 调用浏览器)并搜索方法的名称。

When the breakpoint is hit, you can view the entire call stack. You can bring that window up by going through the Debug menu->Windows->Call Stack.

You can also bring it up by the shortcut Alt+Ctrl+C

EDIT:
You can also right-click on a function name, and view the "Callers Graph", which will show you all the callers for your method. Alternatively, you can bring the Call Browser (by going to View->Other windows->Call Browser ) and search for your method's name.

め可乐爱微笑 2024-08-06 10:37:07

如果您在用户设置的断点处看不到调用堆栈中的任何内容,通常意味着它是从本机代码调用的。

另一种无法获取堆栈的情况:您点击“调试”>“全部中断”并且主线程处于等待/睡眠状态,调试器在构建调用堆栈时可能会出现问题。 我相信调试器使用主线程进行隐式函数评估。

尝试附加(或启动)混合模式(本机和托管)代码调试器,看看是否可以解决问题。

If you can't see anything in the call stack at a user-set breakpoint, it generally means it was called from native code.

Another case where it can't get a stack: You hit Debug>Break All and the main thread is in a wait/sleep state, the debugger can have problems building the call stack. I believe the debugger uses the main thread for its implicit function evaluation.

Try attaching (or launching) the mixed-mode (native & managed) code debugger and see if that straightens it out.

不必你懂 2024-08-06 10:37:07

如果您在“调用堆栈”窗口中看不到任何内容,则肯定有问题。 我建议使用著名的 R 操作序列:

  • 重试
  • 、重新编译、
  • 重新启动
  • 、重新安装:)

If you can't see anything in the Call Stack window, then there's definitely something wrong. I would suggest the famous sequence of R-actions:

  • Retry
  • Recompile
  • Restart
  • Reinstall :)
尘曦 2024-08-06 10:37:07

如果断点位于由事件引发的函数中,您可能没有返回调用者的直接调用堆栈,并且需要启用查看所有代码,而不仅仅是“只是我的代码”。

If the break point is in a function that is raised by an event, you might not have a direct call stack back to the caller, and will need to enable viewing all code, and not just "just my code".

似梦非梦 2024-08-06 10:37:07

对于 Visual Studio 2019 打开查看菜单并选择调用层次结构
或者只需按CTRL+ALT+K

For Visual Studio 2019 Open View menu and select Call Hierarchy,
or simply press CTRL+ALT+K

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文