如何关闭从visual studio中打开的“孤立”控制台窗口?(How to close an “orphaned” console window that was opened from within visual studio?)

在Visual Studio中使用控制台应用程序时,我将按F5运行该应用程序,使其进入调试模式。 偶尔(我不确定这是怎么发生的),我会回到Visual Studio中的“编辑模式”,调试后的控制台窗口仍然会打开。

它将保持开放但完全没有反应。 右键单击窗口并单击“关闭”,我无法关闭窗口; 我无法通过任务管理器关闭它,我无法通过结束特定进程(据我所知)关闭它。 事实上,如果没有按下电源按钮重新启动计算机,我甚至无法退出Windows。

如何让窗口关闭而无需重新启动计算机?

系统信息:Windows XP SP3,Visual Studio 2010

编辑:它通常发生在我进入调试模式后。 所有异常都会冒出来并打印到控制台,所以这不是因为异常导致应用程序中断,而是有时候我会遍历应用程序,直到遇到应用程序的异常被捕获的部分 ,但在它真正出现之前被扔回UI。

When working on console applications in Visual Studio, I will run the application by pressing F5 to bring it into debug mode. Occasionally (and I'm not sure how this happens), I'll get back into "edit mode" in Visual Studio and the debugged console window will still be open.

It will remain open but entirely unresponsive. I can't close the window by right-clicking the window and clicking "close"; I can't close it via the Task Manager, and I can't close it by ending a particular process (to my knowledge). In fact, I can't even exit Windows when this happens without physically pressing the power button to reboot my computer.

How can I get the window to close without having to reboot my computer?

System Info: Windows XP SP3, Visual Studio 2010

EDIT: It usually happens after I break into debug mode. All exceptions are bubbled up and printed to the console, so it's not because the exception causes the application to break, but sometimes I do step through the application until I get to the part of the application that the exception is caught, but before it actually gets thrown back to the UI.

最满意答案

我一直有几乎同样的问题,并找到了一个不同的解决方案,所以发布在这里,以防它帮助其他人...

在我的情况下,我正在运行XP SP3和VS 2005.如果我停止调试控制台应用程序(有时),命令窗口将不会关闭。

问题在于进程实际上已经退出,它不会出现在任务管理器中,所以无法对窗口或关闭进行任何操作。 窗口仍然响应标记/复制/粘贴/滚动等,但就是这样。

在MS支持上找到了一个热门修补程序: http : //support.microsoft.com/kb/982551

I've been having ALMOST the same problem, and found a different solution, so posting here in case it helps someone else...

In my case I'm running XP SP3 and VS 2005. If I stop debugging the console app (sometimes) the command window won't close.

The problem is the process has actually exited, it simply doesn't appear in task manager, so there's no way to do anything with the window or shutdown. The window remains responsive to mark/copy/paste/scroll etc, but that's it.

Found a hot fix here on MS support: http://support.microsoft.com/kb/982551

更多推荐