在 C# 交互中获取调试器上下文
C# Interactive 似乎比立即窗口强大得多(至少它可以处理 LINQ 中经常使用的 lambda 表达式 - 请参阅 Visual Studio 调试“快速观看” “工具和 lambda 表达式),但看起来它不能用作替代品,因为它不知道调试器上下文。有没有办法访问调试器上下文?
我已经看到在 F# 交互式中获取调试器上下文,它可能需要相同的东西,但也许有新的/不同的东西可用。
http://extendedimmediatewin.codeplex.com/ 可能有用,但看起来很死,尽管有人在 10 月 18 日说2011 年,他计划将其移植到 VB.Net ( http://extendedimmediatewin.codeplex.com/discussions/75589)。
C# Interactive seems a lot more powerful than the Immediate Window (at least it handles lambda expressions that are often used in LINQ - see Visual Studio debugging "quick watch" tool and lambda expressions), but it looks like it can't be used as a replacement as it doesn't know about the debugger context. Is there a way to have access to the debugger context?
I've seen Getting debugger context in F# interactive and it might require the same things, but maybe there are new/different things available.
http://extendedimmediatewin.codeplex.com/ could be useful but looks quite dead, although someone said on Oct 18 2011 that he was planning to port it to VB.Net ( http://extendedimmediatewin.codeplex.com/discussions/75589 ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不是一个完整的解决方案,但在 VS2015 中,运行初始化与项目交互后,可以使用调试 > 附加到进程以连接到
InteractiveHost.exe
进程。然后您可以调试项目中的函数。不过,正如 Kevin 解释的那样,您将无法在交互窗口中调试一次性函数。
作为旁注, https://stackoverflow.com/a/40650343/467110 指出您可能必须在打开解决方案之前打开一个 C# 交互窗口,以便成功初始化与项目的交互
Not a complete solution, but in VS2015, after you've run Initialize Interactive with Project, you can use Debug > Attach to Process to connect to the
InteractiveHost.exe
process.You can then debug functions from your project. You won't be able to debug one-off functions in the Interactive window, though, as Kevin explained.
As as side note, https://stackoverflow.com/a/40650343/467110 points out that you may have to have a C# Interactive window open before you open your solution in order to successfully Initialize Interactive with Project
免责声明:我在 Microsoft 的 Roslyn 团队工作。
不幸的是,我们现在没有办法获取调试器上下文。我们知道这很有用,随着 Roslyn 的更多核心交付成果完成,我们希望进行更多调查并看看可以做什么。
Disclaimer: I work for Microsoft on the Roslyn team.
Unfortunately, we don't have a way to get the debugger context right now. We are aware that it would useful, and as we get more of the core deliverables for Roslyn completed we hope to investigate more and see what can be done.
在 C# Interactive 中,您可以运行
来请求调试器,您将看到一个窗口,要求您选择打开的 Visual Studio 实例之一或要附加的新实例。假设您使用了 Visual Studio 的“加载 Interactive with the Project”选项 - 当 Interactive 运行代码时,现在将命中打开的解决方案中的任何断点。
如果您需要没有预先存在的代码的调试器 - 您现在可以将
调用插入到您放入 Interactive 的代码中(但它必须进入一个“块”,即按一下“enter”键),并且您将能够通过“本地”窗口检查本地变量,并通过“立即”窗口针对交互式上下文运行代码。
Inside C# Interactive you can run
to request a debuger, whereby you will get a window asking you to choose one of the open Visual Studio instances or a new instance to attach. Assuming you used "Load Interactive with the Project" option of Visual Studio - any breakpoints in the open Solution will now be hit when code is ran by Interactive.
If you need the debugger without pre-existing code - you can now insert
calls into the code you put into Interactive (but it does have to go in one 'chunk', i.e. one press of 'enter'), and you will be able to examine local vars via 'locals' window and run code against interactive context via 'immediate' window.