Visual Studio 2015: Debug session does not terminate properly - debugging

I've recently picked back up a year old MVC5/WebAPI2 (and SignalR) application which ran just fine under VS2013.
In VS2015 I however keep struggling with what appears to be hanging debug sessions: When starting a debug session VS2015 hangs on "Build succeeded" with no output in the console. The solution is to terminate the IIS Worker Process (which appear locked at 20-30% CPU Usage) via the Task Manager. Upon doing that VS throws a general error message and stops. When retrying once again it works normally until next stop-then-start.
It makes no difference if I stop (Shift+F5) the debug session or restart (Ctrl+Shift+F5) it, either appears to lock up the IIS process. What however does work is going to Debug -> Terminate All, then the debug session starts without hick-up.
I have tried disabling pretty much all debug tools (including Edit-and-Contiune), but nothing has worked so far. I should also mention that running the application on IIS Express does not work at all: It hangs during startup no matter what.
Update: Attaching the error message that pops up if I let the debug startup process time out. I have of course tried all the suggested solutions which the "help" button takes me to.
Update II: It looks like the problem might be related to SignalR. I've been working without problem for the last hour or so, but now stepped into the part of the application which uses SignalR. After stopping and changing some code, the debug session would not start again.

Ensure that you turn on ‘Internet Information Services Hostable Web
Core’ along with all the other .NET / IIS feautes
Try to Change the IIS Settings Shown in this Article

I have the exact same problem, and the solution was to install signalR performance counters.
SignalR performance counters
Similar question with solution: SignalR makes IIS hang after rebuild

Related

Stopping / Killing a debug thread in IntelliJ

I like to stop the execution of a debug thread that I run in IntelliJ Ultimate 2019.3.
I can stop the entire JVM process, but that will require to restart the web application that takes a lot of time to spin up.
I found this request for such a feature (back from 2015), but I see no new way to do it.
Following y.bedrov comment, the solution was indeed to get to the "Throw Exception" wizard and then to enter there
new RuntimeException("error")

Debugging Spawns A Non Terminable Process, and CLI not launching

I've been fighting this little problem for a while now, so I'm really hoping I can get some help. I've been looking for a solution to this, and I found this SO question: Debugging doesn't start.
My issue is somewhat similar to the issue discussed here, except that my issue is a two-parter.
Part 1: Similar to the issue discussed on the other question. (Debug Window Doesn't show up)
When I attempt to launch my Windows 32 console application project (The simple kind that opens in the windows CLI). The CLI (or CMD) window doesn't open, and windows idles giving me a spinning cursor wheel. Visual Studio IDE (I'm using VS 2013 Community) becomes unresponsive and I cannot access any menus, or use any hotkey to "Stop Debugging". One difference from the provided SO question though, is that when I try to launch "MyProject.exe" from my project's "Debug" folder I get the same result as attempting to debug in the IDE.
Part 2: Unkillable Process
When I try to close my debug application in the windows task manager, it is not listed as an ongoing process. However, whenever I try to manipulate, delete, or otherwise modify my Project.exe application (in my Project's "Debug" folder), windows informs me that the application is in use. Confused by this, I downloaded two applications. The first was Process explorer, which showed me that I did in fact have 2 instances of "MyProject.exe" running. The second was Process Hacker, which also showed me 2 instances of "MyProject.exe". However, neither of these programs were able to terminate either of the "MyProject.exe" processes.
I am capable of terminating the processes for visual studio and restarting the IDE, however, because the "MyProject.exe" processes are still running. Building always fails with the error
"Error 1 error LNK1168: cannot open C:\Users\Brandon\Desktop\MyProject\Debug\MyProject.exe for writing"
Whenever I restart my computer, the lock files (as expected) are removed, and the "MyProject.exe" processes disappear. I can restart VS and everything works, but if I try to Debug (pressing "Start Debugging" or F5) the same issue occurs.
A process of my program is started ("MyProject.exe"), but the CLI window where my program's text should appear doesn't show up. Visual studio locks up, and "MyProject.exe" persists until the next restart because "MyProcess.exe" cannot be terminated.
My solution configuration is set to "Debug", Solution Platforms = Win32.
I have tried creating a new blank console project in VS 2013 and I get the same result: code builds fine, but I have the same debugging issue. I get an identical result with a quickly assembled "Hello World" project.
Sorry for being a noob, but honestly. I really don't know what's going on, so any help is greatly appreciated.
(Note: Running Windows 10 with VS2013)
EDIT (UPDATE):
So, I'm having the same problem with several programs in Windows 10 (most notably Allegorithmic's Substance Painter). So it looks like this may actually be an OS problem. Several of my programs whenever I try to launch them do the same thing...the program acts like it's going to launch, but then no usable window appears. Looking at my processes I can see that the process has been started, but it is once again unkillable. For reference, I am using Windows 10 Version 1511 (OS Build 10586.17).
I believe your problem might be Avast, if you are running it. I had exactly the same issues until I uninstalled it. Had upgraded to Win10 and VS2013 just froze, same as you described.
Cheers.

Visual Studio 2012 high CPU usage and unable to debug

I'm using Visual Studio 2012 Update 3. When I open a project, VS automatically creates a process called <myproject>.vshost.exe, even before starting to debug.
When I start debugging and later close the debug application, most of the times the <myproject>.vshost.exe process closes as well. When this happens, devenv.exe starts taking up 3x more memory than normal and CPU goes up to 25% (on a i7 Quadcore with 8GB ram) for around 1 minute. At the end of 1 minute, a new <myproject>.vshost.exe opens up (even though I'm not debugging), CPU falls back down to 0 and memory drops back down as well.
Trying to start debugging whilst the CPU is at 25% and <myproject>.vshost.exe is not running in the background will results in the solution building but the debug does not start.
If I wait until the CPU falls back down and <myproject>.vshost.exe process is running again then I can start debugging normally.
This happens to me 80% of the times after closing the application I am debugging. The remaining 20% of the times when I stop debugging <myproject>.vshost.exe continues running in the background and I am able to start debugging again immediately after with no delay.
This also happens regardless of code changes in between debugs.
This is a new install of VS2012 U3, I've tried resetting all settings and disabled ReSharper but still no joy.
I don't want to disable vshost debugging because of the features I would lose.
Has anyone else encountered this problem before? Is this a known issue? Are there any solutions/workarounds?
EDIT
I changed the platform from Any CPU to x86 and it appears to work properly, but I still can't understand why I shouldn't be able to debug it as Any CPU. Even though this might be the workaround I'd still be interested in knowing whether this is a known issue and if there are other (better) solutions.
By 'working properly', I mean that when I stop debugging the vshost doesn't close, in fact it never closes, but the CPU of devenv stays at 0% and it allows me to start and stop debugging as many times as I want one right after the other.
EDIT2
Actually it appears that changing the platform to x86 only worked properly for a while, after about 20 rebuilds it is now doing the same as leaving it as Any CPU.
On another note, closing and opening VS makes no difference.
I've ended up formatting the computer again and re-installing everything from scratch. For not it appears to be working fine, let's see how long this lasts for.
I know this is several months old but I'm trying to post this answer in a few places since this is what was causing my ills: I had the Data Sources toolbox open in Visual Studio 2012. Once I closed that, it seemed to eliminate the lengthy delays when switching windows. You may also want to close Server Manager if you don't need it open.
I know this is old Post but, I think I need to share my solution for everyone.
and this is my first post so, please improve the answer if I miss something.
I have the same issue with Visual Studio 2012, When I try to build or debug it will use CPU up to 100%.
So, I try below steps to reduce the CPU usage while debugging:
Please close unnecessary opened file.
Hide unnecessary debugging panels like: breakpoints, auto, local, output, find symbol result, etc.
If still use high CPU then try to hide call stack panel.
Remove unnecessary breakpoints.

Visual Studio 2008 hanging in 64bit Windows 7

I have brand new Win7 64bit machine. Visual Studio 2008 is newly installed, but has started responding more and more slowly, eventually hanging completely and occupying one (virtual) core of the machine completely. After an hour or so of increasingly slow response I close it and start again, whereupon it runs fine at first before gradually slowing down again.
Using Process Explorer I have found that the responsible devenv.exe thread always has a stack which looks something like this when it is pegging the processor:
ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x732
ntoskrnl.exe!KeWaitForMutexObject+0x19f
ntoskrnl.exe!__misaligned_access+0xba4
msenv.dll!DllCanUnloadNow+0x49b31
with one or more ntoskrnl.exe!__misaligned_access and msenv.dll!DllCanUnloadNow lines; can anyone give me an idea of what might be going wrong? Thanks!
UPDATE:
Having started VS via the command line switch /SafeMode (thanks 0xA3), I find that without Resharper the problem seems to go away... So it looks likely to be a Resharper bug :(
did you check all other threads in the process? (both managed and un-managed) to see if any thread is busy or waiting in non-trivial place with stacks unlike others? Main thread is obviously waiting, most likely on another thread of the same process - I'm curious to know what other callstacks are out there.

Visual Studio 2010 hangs on debug start for a minute or two

VS2010 hangs for several minutes after debug starts, after that debugging continues as usual. I have no idea what it's doing, Process Explorer says the debugged process is in suspended state during that hang and Visual Studio doesn't seem to write anything to disk except a few kB at the end of the hang.
There was no such hang for over eight months in any of my projects, it started yesterday.
UPD: Resetting all settings cured a lot of problems including this hang. I still don't know what it was, but resetting works magic.
I've noticed this as well and have determined that one of the causes is any code that uses interrupts or timers. Allegro 4.x (no comment on 5.x as I have not used it yet) is a big offender. Simply including and calling the global initialization method for the timer routines will cause this to happen.

Resources