Visual studio debug console sometimes stays open and is impossible to close - visual-studio

EDIT #3 : Microsoft has released a 'fix' to this problem which is available here. I haven't had the time to test it, but I those who want to are welcome to leave their feedback here !
Sometimes when I run an application from Visual Studio and it crashes or I stop it using the stop button in the debug menu (Debug->Stop Debugging (Shift-F5)), the console of said application stays open... and never closes. I cannot close it by clicking the 'x' button in the top right corner. I cannot kill the process as it is not even listed in taskmgr.
I have seen this problem documented in different places on the web, but no solution so far.
I am running on windows XP SP3, using visual studio 2008 w/ SP1.
1- What could be causing this ?
2- Is there a fix ?
thanks alot.
JC
EDIT: There is no MyApp.vshost.exe process to close, and closing visual studio does not close the console either. Worse even, if I try to restart my computer windows will hang and never close, I need to do a forced shut down.
EDIT #2 : (from Brad Sullivan, Program Manager - Visual Studio Debugger on March 2nd)
[...] this issue is likely not in Visual Studio since it also occurs in scenarios where Visual Studio is not present. We are in the process of handing over our investigation to the Windows Servicing team.
But for now, removing the KB978037 update and it's related files seems to work.

This is a bug introduced in security update KB978037. Back out this update and you'll be back to normal.
Also see here:
http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/e6d4a4f5-7002-401a-90e1-6174d7f9e3ca

Microsoft has released a 'fix' to this problem which is available here. I haven't had the time to test it, but I those who want to are welcome to leave their feedback here !

There are a couple of things that could be happening here. Try closing down the following process and see which one, if any close down the Console application as well.
The Hosting Process: Typically named YourExecutable.vshost.exe
Visual Studio
If closing the hosting process fixes the issue then one quick work around is to disable the hosting process itself.
Right Click on Project -> Properties -> Debug -> Uncheck the hosting process
If closing down Visual Studio fixes the problem then it's potentially a bug in Visual Studio. Please file a bug on connect.
http://connect.microsoft.com

Visual Studio Debugger Team has already acknowledge this issues on their blog. check the below url for more information.
http://blogs.msdn.com/debugger/archive/2010/03/11/help-my-console-windows-won-t-go-away.aspx

Related

msvsmon.exe crashed when debugging

When I debugging in VS2013 update3, msvsmon.exe crashed when hit at a breakpoint.
It shows "The debugger's worker process (msvsmon.exe) unexpectedly exited. Debugging will be aborted".
I'm not using remote debug.
Is it possible to shut down the msvsmon.exe to avoid calling it when debugging ?
Deleting all of the breakpoints solves the problem when I hit this error. Disabling the breakpoints was not enough - they had to be deleted.
I was able to attach to a process numerous times. Once I added a conditional breakpoint (with a few checks), I started getting this error when attempting to attach to that same process.
The error provided in the question is one problem. I also received an error stating that a debugger was already attached when I tried again. Either way, deleting breakpoints solved it.
Try turning on Options > Debugging > General > "Use Managed Compatibility Mode"
I got this error/crash too while debugging and trying to inspect a variable with 50 MB of text data in it. This option worked in both VS2013 and in VS2015 to allow me to debug and inspect the variable with large data.
A couple of things that worked for me:
Try Closing VStudio and relaunching.
If not, reboot helps.[I know thats generic, but its worth a shot]
Disable unnecessary break points.
I had this error also, and I too have Astrill installed. Completely uninstalling Astrill fixed the issue.
I reached out to Astrill support, and they answered (within 2 hours) saying the correct fix is to hold Ctrl and press the "Help" button on the Astrill application, and then choose "Uninstall LSP". This has fixed the issue without needing to un-install Astrill.
I don't know what LSP is, but I presume it's some sort of proxy.
In my case, it was caused by a VPN software. It changed my hosts file and my localhost was not 127.0.0.1 anymore.
So check your localhost in the hosts file (e. g. %WINDIR%\System32\drivers\etc\hosts) and make sure it is 127.0.0.1.
This error just occurred for me with visual studio 2015 RTM. Deleting all the breakpoints resolved the "The debugger's worker process (msvsmon.exe) unexpectedly exited. Debugging will be aborted" condition.
So If you clear all your breakpoints, in your version, you will not need to avoid using MSVSMON.exe.
I was using the OzCode debugger extension. Unfortunately they don't have a way to completely disable the extension - you can only disable certain features - so I had to completely uninstall it to confirm it was what was contributing to the crashes.
I got the same error. No effect after deleting all breakpoints and repairing Visual Studio (I have 2013 Community Edition). The problem was the Bitdefender software. I have Bitdefender Internet Security 2016 and had set Active Thread Control (Modules->Antivirus) to Normal level. But after setting this settings to Permissive the error doesn't show up anymore.
This error occured to me, when I tried to debug with Visual Studio / Service Pack 3, when Service Pack 4 was already released. After updating to the Service Pack 4 I was able to debug.
So, try installing the newest version of Visual Studio
Regards
This (or something that manifests in exactly the same way) is still an issue in VS2017. In my case it was caused by a dependency being too large to debug. The dependency in question was a generated client for a large REST API. I was able to debug again after slimming down that dependency.
Here's yet another answer: I changed my project from "Platform Target: Any CPU" to "Platform Target: x86". Went from needing about 5 attempts to debug to working every single time.
I had previously tried every suggestion in this thread: I reinstalled, I killed all breakpoints, and looked for fishy software interactions.
I started getting this exact error today in my VS2019 project. Attempting to expand/inspect simple data structs in VS debugger would make it freeze for a minute and then I'd get that "The debugger's worker process (msvsmon.exe) unexpectedly exited. Debugging will be aborted" message:
If I add msvsmon.exe process to windows defender exclusions list, then the problem disappears.
I hit this in Visual Studio 2019 (16.4.3) (C++) with a cause that I have not seen mentioned: I had accidentally added a Watch with incorrect syntax that was attempting to instantiate a singleton rather than returning the existing instance.
Repeatedly choosing right click > Clear All in the Watches view while debugging fixed the issue.
Fixed by changing Options->Projects and Solutions->Web Projects -> Use 64bit version of IIS......... to False.
In my case i am using the wcf Service on the wpf application and inputting parameters from here.The Wpf Application Execution on Facing this error "The debugger's worker process (msvsmon.exe) unexpectedly exited. Debugging will be aborted".
That case i am hosing the Wcf service and run the wpf application exe
In this type of Execution on I didn't Facing any Error like -- "The debugger's worker process (msvsmon.exe) unexpectedly exited. Debugging will be aborted"
please,try this proceed error solved because some execution process didn't supporting the debugging..... we are removing the Debuggers on also we face same error.
that case on helped this process.......
I just experience this with VC2017 Community Edition 15.7.2. Turning off the Microsoft Symbol Server lookup while debugging fixed it for me.
I've just had the problem in VS 2015. I hadn't noticed that one of my breakpoints was bogus - I had inadvertently pressed F9 to set a breakpoint when the disassembly window was showing in the previous debugging session. The solution was simply to delete that one bogus breakpoint - I got to keep all my others.
I tried almost every answer in here, but for my case, nothing worked.
Switching to 32-bit just made Visual Studio 2019 crash instead of msvsmon.exe crashing.
What did work for me is to set a very early breakpoint and use that opportunity to close the "Parallel Stacks" window. I didn't need that anyway, but it was open by default in my layout.
In my case, I had this error when I had the "Locals" tab opened during debugging and hitting a breakpoint. For some reason VS might've been unable to display one of the local variables. The error disappeared when switched to a different tab before hitting the breakpoint where the error was occurring.
My problems started after moving a project to a new folder. I wasn't having any luck with any of these answers using VS2019. I even deleted the entire .vs folder thinking maybe something got corrupted. No luck.
But on a whim I tried starting the project with CTRL-F5 instead of just F5 and that actually worked. It's consistent. CTRL-F5 runs fine. F5 gives me the msvsmon.exe error.
I have no idea what's going on, but at least I can get the project to run again.
This problem is at least 1 1/2 years old maybe more. Today is 6-11-22 and I have the problem in Ms Studio Pro 2022 with a fresh install of windows 11 not much of anything else in the computer. Then I uninstalled it and install Ms Studio Community 2022 put in 1 breakpoint at the beginning and I got the error.
Today 6-12-22 I reinstall Ms Studio Community 2022. For some reason I switch from x86 to x64 went through a about 1000 changes of errors and a crashed form1.resx file thank goodness for a backup I had or I'd be done again. anyways so far have several break points with no problems.
I deleted all my watch variables. That fixed the problem for me.
I know it doesn't directly address the error, but as a workaround, I'm using the Rider IDE from JetBrains, and am not encountering the error (code, system, etc. the same).
Visual Studio version: Professional 2017, 15.5.4
Rider version: 2017.3
None of the other answers worked for me, when I encountered this error. If you are not actually remotely debugging, you can use another editor until you figure out the problem or it resolves itself (the latter was the case for me).

Prevent to start "Debugger-Windows" from first application start in Visual Studio

When I start a program from Visual Studio it also starts several (about 6) additional windows I guess they show some resource information.
My problem is that those windows seems to freeze the whole progam. I cannot close them and have to restart Visual Studio. Is there a way to prevent them to open when I start a application from Visual Studio?
EDIT(Screenshot added):
EDIT: After a downvote without a comment, it looks like i have to add my affords:
Googled over an hour, but because those boxes crashes I dont see what they are supose to be. So I dont know for sure what to look for.
Enabled and dissabled all Debbuging option without any effect.
EDIT: Its a default C# WPF app.
EDIT: Title
Thank you.
Its a TeamViewer issue.
Debug doesnt work in with TeamViewer running.
You have to close TeamViewer.
Start debugger
Close all debugging windows (Watch, Memory)
End debugger
You can now open Teamvierwer again
Source:
https://connect.microsoft.com/VisualStudio/feedback/details/817590/microsoft-visual-studio-express-2013-for-windows-desktop-hangs-on-debug

Visual Studio 2010 hangs on attach to process / debugging

Whenever I try to debug a Visual Studio 2010 web project, VS hangs, and ultimately crashes. This happens if I try to start the project using F5, or through Attach to Process, before the process list even appears.
Hitting F5 in, for example, a Windows Form project works fine, but attach to process fails here too.
Any ideas on what can be causing this? Obviously attaching to the devenv.exe process won't work as I can't get the Attach to Process dialog to appear...
Oh, running W7 (x64), VS2010 SP1 (had same problems without SP1)
In Solution Explorer there is a Show All Files icon (highlighted in the photo below):
Make sure it's turned off,
When It's turned on, Visual Studio tries to index all the files in the solution and if you have a giant Solution it could take forever!
I hope this has helped someone :)
Have you recently installed Mono and/or Mono Tools for VS2010?
I found that to be the problem it my case. Not sure why, but it somehow got in the way.
Matthew
In my case hangs when executable type was not correctly set, ex. Managed v4.0 and trying to attach to Native.

VS attaching to process disabled

A few days ago, the attach button in "Attach to process" dialogue became disabled in VS 2010 and VS 2008 likewise. At first I thought that it is just an extension I've installed in VS 2010 but then I noticed it is the same in VS 2008. The both VS's a re running in administrative mode and on Windows 7.
I looked around but I can't seem to find a solution to this.
If anybody has encountered an similar problem, a little help would do great.
Thanks upfront.
EDIT: Attached a picture of the dialogue!
Where it says
you should press 'Select' and ensure at least managed is ticked. (or choose automatic)
otherwise, the 'Attach' button will be disabled.
It could also be because there is already another debugger attached to the process - probably the currently running instance of Visual Studio but it may be another instance of Visual Studio, or another debugger entirely (such as WinDbg or a remote debugging session).
Check the "Processes" window (usually found under Debug -> Windows -> Processes) to see what processes Visual Studio is debugging.
Try stopping Visual Studio but don't close the process.
I have come across a weird situation under which Attach button was disabled. This was because of DebugDiag. Please refer the following thread for info.
I was trying to debug a windows service as described here and had the same issue. The solution was to run Visual Studio as Administrator and select to see processes from all users.

Visual Studio detaches from application as soon as debugging starts

I have a web application that I've always been able to run in Visual Studio and it debugs just fine (breakpoints work, I can pause execution, etc). Recently, the behavior changed suddenly, and a few things happen:
I start debugging, it lauches IE and loads the application, but after a few seconds (sometimes the page hasn't even displayed yet), Visual Studio acts as if debugging has stopped - I'm able to edit code in VS again, and the "Play" button on the toolbar is enabled. The application continues to run in the IE window just spawned, but I'm not attached to it
During this few seconds that VS is "debugging", because it detaches, my breakpoints show as hollow - as if I'm set to "Release" mode and they won't be hit. In fact, I have a breakpoint set in Page_Load, and it skips right by. I've checked, and I'm set to debug mode, though the compile mode dropdown is missing from my toolbar (I checked in the build properties to ensure I was in debug mode).
Can anybody shed some light here?
It turns out that this was actually a result of an upgrade to Windows Vista. VS wasn't being "Run as an Administrator", which caused it to lack the rights to attach to other processes for debugging. As a result, debugging would stop right after it started. Changing the VS shortcut to run as an administrator resolved this problem.
I've experienced samely looking behavior. The cause was in existence of several <system.web> sections (which is allowed by web.config schema). Visual Studio debugger (versions 2008 and 2010 were tested) looks in the first encountered section only. So if your <compilation debug="true"> tag is not in the first one, it thinks that there are no compilation.debug setting present and genrally tryes to add <compilation debug="true"> to the first <system.web>. In some cases VS2008 just silently procceds in this case. For example look here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=510354#details"
Have you installed anything else on the server / workstation recently?
We have a third party app that doesn't allow us to debug, w3wp.exe crashes immediately upon an attempt to debug.
I ran into something similar when I had placed some code in a constructor that was crashing. Exact same issues where the Debug would disconnect just after the application started up.
The short if it, check that you haven't configured a class constructor to run during web startup that is crashing...
Quick windows 7 update: I had to add "localhost" to my list of trusted sites to correct this issue...go figure.
Just a workaround for those (like me) for whom the above solutions do not work: After starting the app you wish to debug, go to Debug -> Attach to Process, and attach it to the process you want to debug. Works on my machine.
In my case, I faced this issue with Visual Studio 2019 and 2022 as well.
I tried upgrading/downgrading Visual Studio versions but nothing helped.
On debugging, I finally found the root cause and sharing it here to help others facing the same problem.
I was using Brave browser with Visual Studio and whenever I uploaded a file in my application, the Visual Studio debugging stopped automatically. The root cause of this issue is the feature in Visual Studio to stop debugging on closing the browser. With Brave browser Visual Studio feels like we have closed the browser on uploading the file. So to fix this issue I have turned of this setting as given here.
You can find this setting here
Tools > Options > Projects and Solutions > Web Projects > Stop debugger when browser window is closed, close browser when debugging stops
Just turn it off and everything should work fine.

Resources