简体   繁体   English

Visual Studio Watch window 变灰了吗?

[英]Visual Studio Watch window greyed out?

I have a VB app that I need to monitor while it is running.我有一个 VB 应用程序,我需要在它运行时对其进行监视。 I added some variables to the Watch window, but while the app is running the watch window is greyed out.我向手表 window 添加了一些变量,但是当应用程序运行时手表 window 是灰色的。 The only way that I have found to see the variable values is to use Debug -> Break All, but this stops the program.我发现查看变量值的唯一方法是使用 Debug -> Break All,但这会停止程序。

I have used other IDEs and they allow active variables to be monitored.我使用过其他 IDE,它们允许监视活动变量。 Is this possible in VS?这在 VS 中可能吗?

Sorry if this is a noob question.对不起,如果这是一个菜鸟问题。

UPDATE: To be clear, my app is communicating with a piece of lab equipment and and as data is sent or received or errors are detected counters are incremented.更新:明确地说,我的应用程序正在与一台实验室设备通信,并且随着发送或接收数据或检测到错误,计数器会增加。 I would like to watch these counters but I don't want to build a screen to do this since they are for debugging.我想看这些计数器,但我不想构建一个屏幕来执行此操作,因为它们用于调试。 I just assumed that this is basic functionality in any IDE我只是假设这是任何 IDE 中的基本功能

SHOCKED: It seems that Visual Studio does not offer this (what I would consider) basic functionality.震惊:似乎 Visual Studio 不提供这个(我会考虑的)基本功能。 For those that seem to think that this is not possible with an interpreted language, consider this thought experiment.对于那些似乎认为解释性语言不可能做到这一点的人,请考虑这个思想实验。 If you pressed Break All quickly followed by a Continue then you would refresh the watch window - correct?如果您快速按 Break All 然后按 Continue,那么您将刷新手表 window - 对吗? Why then can't Visual Studio do this as a single Refresh Watch command or better yet allow this function to automatically run at a period specified by the user.为什么 Visual Studio 不能将此作为单个 Refresh Watch 命令或更好的方式执行此操作,但允许此 function 在用户指定的时间段自动运行。 No debug writes, no log files, no stopping your program mid-stream and creating timeouts.没有调试写入,没有日志文件,没有中途停止程序和创建超时。 I am just shocked that you cannot do this.我很震惊你不能这样做。 Its a little like not having breakpoints.这有点像没有断点。

Which IDE or development environment shows - in real time - the values of variables in the Watch window, without having to hit any breakpoints, while the application is running? 在应用程序运行时,哪个IDE或开发环境实时显示Watch窗口中的变量值,而不必点击任何断点?

Visual Studio doesn't provide this. Visual Studio不提供此功能。 In order to get updated values in the Watch window, or edit items there, the app needs to be at a breakpoint or debugging. 为了在Watch窗口中获取更新值,或在那里编辑项目,应用程序需要处于断点或调试状态。

After you've done "break" to give control of the program to the debugger, then you can "step" through the code using function keys like F10 and F11. 在完成“break”以将程序控制权交给调试器之后,您可以使用F10和F11等功能键“逐步”执行代码。 During each 'step', the program evaluates one or more statements; 在每个“步骤”期间,程序评估一个或多个语句; after each step it stops (until the next step), and while (only while) it's stopped you can 'watch' its current state. 在每一步之后它停止(直到下一步),同时(仅在)停止时你可以“观察”它的当前状态。

There are other ways too to break into the debugger (to use the Watch window while the program is stopped): other ways like to set 'breakpoints', and use the 'run to cursor' feature. 还有其他方法可以进入调试器(在程序停止时使用Watch窗口):其他方法如设置'断点',并使用'run to cursor'功能。


Of course, but stopping a program that is actively receiving or sending data to a some other process, driver, etc, stops this communication and causes timeouts and other problems. 当然,但是停止正在主动接收或向其他进程,驱动程序等发送数据的程序会停止此通信并导致超时和其他问题。

That's true. 确实如此。 To watch values change in real-time, I use a log file: 要实时观察值的变化,我使用日志文件:

  • Add statements to my code, such that when I change the value of a variable I emit a new line to a log file (showing the changed value) 将语句添加到我的代码中,这样当我更改变量的值时,我会向日志文件发出一个新行(显示更改的值)

  • Run the program 运行程序

  • Watch new lines being appended to the log file using a utility like tail -f . 使用tail -f等实用程序观察添加到日志文件中的新行。

I've never see a debugger with the functionality you mention. 我从未见过具有您提到的功能的调试器。 The closest thing to the functionality you mentioned (and which isn't exactly the functionality you mentioned) is How to: Set a Data Breakpoint (Native Only) . 与您提到的功能最接近的(并且不完全是您提到的功能)是如何:设置数据断点(仅限本机)

What you're attempting to do is not possible in Visual Studio. 您在Visual Studio中无法尝试执行的操作。 All of the variable inspection windows (watch, locals, autos, etc ...) rely on the debugee process being in a break state in order to function. 所有可变检查窗口(手表,当地人,汽车等......)都依赖于debugee进程处于中断状态以便运行。

This is true of essentially any debugger I've worked with in the past. 对于我过去使用过的任何调试器来说都是如此。 At least those which use a compiled language. 至少那些使用编译语言的人。

I'm curious as to what IDE's you're referring to? 我很好奇你指的是什么IDE? Did they deal with interpreted languages? 他们处理解释语言了吗?

确保您处于“Debug”构建状态,并且Microsoft Debugger作为服务运行而不是阻止/禁用。

my 88 year old memory remembers an old version of visual studio allowing a watch window to function while debugging.我 88 岁的 memory 记得旧版本的 visual studio 在调试时允许手表 window 到 function。 OK, just me.好的,只有我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM