简体   繁体   English

如何关闭从visual studio中打开的“孤立”控制台窗口?

[英]How to close an “orphaned” console window that was opened from within visual studio?

When working on console applications in Visual Studio, I will run the application by pressing F5 to bring it into debug mode. 在Visual Studio中处理控制台应用程序时,我将按F5运行应用程序以使其进入调试模式。 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. 偶尔(我不确定这是怎么发生的),我将在Visual Studio中回到“编辑模式”,调试的控制台窗口仍然会打开。

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. 事实上,如果没有按下电源按钮重新启动计算机,我甚至无法退出Windows。

How can I get the window to close without having to reboot my computer? 如何在不重新启动计算机的情况下关闭窗口?

System Info: Windows XP SP3, Visual Studio 2010 系统信息: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. 所有异常都被冒泡并打印到控制台,因此不是因为异常导致应用程序中断,但有时我会逐步完成应用程序,直到我到达应用程序中捕获异常的部分,但实际上被扔回UI。

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

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 在MS支持上找到了一个热门修补程序: http//support.microsoft.com/kb/982551

The first part is normal, the console window cannot respond to close requests while the debugger has a the process in break mode. 第一部分是正常的,当调试器具有处于中断模式的进程时,控制台窗口无法响应关闭请求。

Debug + Stop Debugging should terminate the program. Debug + Stop Debugging应该终止程序。 There's however an issue that's specific to XP and earlier, a process cannot terminate if a kernel thread is executing an I/O request for the process. 然而,有一个特定于XP及更早版本的问题,如果内核线程正在执行进程的I / O请求,则进程无法终止。 You can see this condition from Taskmgr.exe, Processes tab. 您可以从Taskmgr.exe,Processes选项卡中看到此情况。 View + Select Columns and tick "Handles". 查看+选择列并勾选“手柄”。 You've got a zombie process when you see it show 1 handle in use. 当你看到它显示1个手柄正在使用时,你有一个僵尸进程。

Not so sure how you get out of the condition, it is rather specific to the I/O request that isn't completing. 不太确定如何摆脱这种情况,它对于未完成的I / O请求非常具体。 Having ditched XP a long time ago, I vaguely remember killing devenv.exe to solve the problem. 很久以前抛弃了XP,我依稀记得杀死devenv.exe来解决这个问题。 Windows 7 is nice, recommended. Windows 7很不错,推荐。

I've had this problem on windows xp in the past. 我以前在windows xp上遇到过这个问题。 Just got it in win 7 for the first time. 刚刚在第7场比赛中获胜。 Man this is annoying. 男人这很烦人。

EDIT: Killing devenv.exe works for me. 编辑:杀死devenv.exe适合我。 Is annoying having to restart sln. 很烦人不得不重新启动sln。

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

相关问题 如何从 PowerShell 控制台中使用 Visual Studio Code 打开文件? - How to open a file with Visual Studio Code from within a PowerShell console? 如何阻止控制台 window 在 Visual Studio 2019 中关闭? - How do I stop the console window from closing in Visual studio 2019? 如何在卸载主窗口时关闭从主窗口的iframe打开的窗口 - How to close windows that was opened from iframe of main window on unload of main window 如何关闭从命令行使用.hta打开的窗口? (不是手动的) - How do I close a window that was opened with a .hta from the command line? (not manually) C ++ Windows:如何关闭控制台窗口? - C++ Windows: How to close a console window? 如何修复控制台窗口关闭的输出警告? - How to fix output warning for console window close? 如何从 python 关闭所有打开的 windows? - How to close all opened windows from python? 如何在给出额外输入的情况下使控制台输出窗口在Visual Studio 2015中保持打开状态? - How to make the console output window stay open in Visual Studio 2015 stay open when extra input is given? 来自 Visual Studio 中控制台项目的 Exe 文件? - Exe file from a console project in Visual Studio? 当用户单击Visual Studio表单窗口内的任何位置时,如何弹出消息框? - How to pop up a message box when user clicks anywhere within the form window in Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM