visual-studio Visual Studio Watch 窗口变灰了?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1110521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Watch window greyed out?
提问by NormD
I have a VB app that I need to monitor while it is running. I added some variables to the Watch window, but while the app is running the watch window is greyed out. The only way that I have found to see the variable values is to use Debug -> Break All, but this stops the program.
我有一个 VB 应用程序,我需要在它运行时对其进行监控。我向 Watch 窗口添加了一些变量,但是当应用程序运行时,watch 窗口是灰色的。我发现查看变量值的唯一方法是使用 Debug -> Break All,但这会停止程序。
I have used other IDEs and they allow active variables to be monitored. Is this possible in VS?
我使用过其他 IDE,它们允许监视活动变量。这在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. 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? 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. 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.
震惊:Visual Studio 似乎没有提供这个(我会考虑的)基本功能。对于那些似乎认为用解释性语言不可能做到这一点的人,请考虑这个思想实验。如果你快速按下 Break All 然后按下 Continue 那么你会刷新观察窗口 - 对吗?为什么 Visual Studio 不能作为单个刷新监视命令执行此操作,或者更好地允许此功能在用户指定的时间段自动运行。没有调试写入,没有日志文件,没有在流中停止你的程序和创建超时。我只是震惊,你不能这样做。它有点像没有断点。
采纳答案by marcc
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. In order to get updated values in the Watch window, or edit items there, the app needs to be at a breakpoint or debugging.
Visual Studio 不提供此功能。为了在 Watch 窗口中获取更新的值,或在那里编辑项目,应用程序需要处于断点或调试状态。
回答by ChrisW
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. 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.
在您完成“中断”以将程序控制权交给调试器后,您可以使用 F10 和 F11 等功能键“单步执行”代码。在每一个“步骤”中,程序都会评估一个或多个语句;在每一步之后它都会停止(直到下一步),并且当(仅当)它停止时,您可以“观察”它的当前状态。
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.
还有其他方法可以进入调试器(在程序停止时使用观察窗口):其他方法如设置“断点”,并使用“运行到光标”功能。
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).
我从未见过具有您提到的功能的调试器。最接近您提到的功能(并且不完全是您提到的功能)是How to: Set a Data Breakpoint (Native Only)。
回答by JaredPar
What you're attempting to do is not possible in 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.
您尝试执行的操作在 Visual Studio 中是不可能的。所有变量检查窗口(watch、locals、autos 等)都依赖于处于中断状态的调试进程才能运行。
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? Did they deal with interpreted languages?
我很好奇你指的是什么 IDE?他们是否处理过解释性语言?
回答by Jimbo
This should help you: How to trace and debug in Visual C++ .NET and in Visual C++ 2005
这应该对您有所帮助:How to trace and debug in Visual C++ .NET and in Visual C++ 2005
回答by Zepplock
Make sure you are in "Debug" build and Microsoft Debugger is running as a serviceand not blocked/disabled.
确保您处于“调试”版本中,并且 Microsoft 调试器作为服务运行并且未被阻止/禁用。

