简体   繁体   English

在Visual Studio立即窗口中清除堆栈

[英]Clear Stack in Visual Studio Immediate Window

When working with the immediate window, one has to differ between runtime and designtime. 使用即时窗口时,必须在运行时和设计时之间有所不同。

If I use the immediate Window on design time and put a local variable in stack: 如果我在设计时使用立即Window并将一个局部变量放在堆栈中:

string s = "test";

VS will start the compiler and create a new variable called s on the Heap and place a Pointer to it on a temporary stackframe it uses during designtime. VS将启动编译器并在堆上创建一个名为s的新变量,并在设计时使用的临时堆栈帧上放置一个指针。 (At least I think thats how it works, at least simplified. Please correct me if I'm wrong, though) (至少我认为这是如何工作的,至少是简化的。如果我错了,请纠正我)

From now on, I am not able to use s for anything else, until I run my application or close VS: 从现在开始,在运行我的应用程序或关闭VS之前,我无法将s用于其他任何事情:

int s = 12;
A local variable named 's' is already defined in this scope

I can use the contextmenu to clear the immediate window, but this really just clears the window itself. 我可以使用contextmenu清除即时窗口,但这实际上只是清除了窗口本身。 My local variables still stay on the stack. 我的局部变量仍然留在堆栈中。

I was wondering, if there is really not way to clear all variables I previously created inside the immediate window? 我想知道,如果真的没有办法清除我之前在即时窗口中创建的所有变量?

(Im using VS 2012 SP1 Prof. but I guess the issue stays the same with every version of VS) (我使用的是VS 2012 SP1教授,但我猜这个问题与VS的每个版本保持一致)

I don't know the exact underpinnings of exactly what happens in visual studio, but it appears that VS keeps a compiled version in a vshost.exe process. 我不知道visual studio中究竟会发生什么的确切基础,但似乎VS在vshost.exe进程中保留了编译版本。

If you kill the associated process (ie WindowsFormsApplication1.vshost.exe *32), it will clear the stack and allow you to reuse the variable without having to restart VS. 如果您终止关联的进程(即WindowsFormsApplication1.vshost.exe * 32),它将清除堆栈并允许您重用该变量而无需重新启动VS.

Design-time debugging is described in this MSDN page . 本MSDN页面中描述了设计时调试。 It is rather short on specific help that would address your issue. 在解决您的问题的具体帮助上相当简短。 The example of Visual Basic code is not entirely by accident, this was an important feature in the VB6 IDE of old. Visual Basic代码的例子并非完全是偶然的,这是旧的VB6 IDE中的一个重要特性。 And certainly more practical in that programming environment since it was common to write procedural code that was easy to test and debug with the Immediate window. 在编程环境中肯定更实用,因为编写易于使用立即窗口进行测试和调试的过程代码是很常见的。

The quickest way I can think of clearing the execution state of the interpreter is to press F11 (Debug + Step Into) and cancel debugging. 我能想到清除解释器执行状态的最快方法是按F11(Debug + Step Into)并取消调试。 Or typing >Debug.StepInto and >Debug.StopDebugging. 或者输入> Debug.StepInto和> Debug.StopDebugging。 Not ideal. 不理想。

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

相关问题 Visual Studio 2013立即窗口和缓慢搜索 - Visual studio 2013 immediate window and searching slow 将XmlReader XML写入Visual Studio中的即时窗口? - Write XmlReader XML to immediate window in Visual Studio? 在Visual Studio即时窗口中自动执行命令 - Automate a command in Visual Studio Immediate Window C#是否可以在Visual Studio中测试是否使用即时窗口的语句? - C# Is it possible to testing if statement using immediate window in visual studio? 在Visual Studio的即时窗口中未捕获到未处理的异常 - Unhandled Exception not being caught in Immediate Window of Visual Studio Visual Studio立即窗口“表达式计算器中的内部错误” - Visual Studio Immediate window “Internal error in the expression evaluator” Linq扩展方法在Visual Studio 2015即时窗口中不可用 - Linq Extension Methods Not available in Visual Studio 2015 Immediate Window 使用 C# 在 Visual Studio 中的即时窗口上运行多行 - Running multiple lines on the immediate window in Visual Studio with C# 如何在visual studio的即时窗口中运行foreach循环? - How can I run a foreach loop in the immediate window of visual studio? 是否可以在Visual Studio 2017的直接窗口中使用数据上下文? - Is it possible to use a Data context in the immediate window of Visual Studio 2017?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM