简体   繁体   中英

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. 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.

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

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. 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. You can see this condition from Taskmgr.exe, Processes tab. View + Select Columns and tick "Handles". You've got a zombie process when you see it show 1 handle in use.

Not so sure how you get out of the condition, it is rather specific to the I/O request that isn't completing. Having ditched XP a long time ago, I vaguely remember killing devenv.exe to solve the problem. Windows 7 is nice, recommended.

I've had this problem on windows xp in the past. Just got it in win 7 for the first time. Man this is annoying.

EDIT: Killing devenv.exe works for me. Is annoying having to restart sln.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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