How to stop debugging (or detach process) without stopping the process? - visual-studio

I often use VS 2008 to debug a .NET C# component of an application. Sometimes, I want to quit debugging and continue running the application. Stop Debugging kills the process I was debugging.
How can I achieve my aim?
This is not a web app, it's a local process that runs managed and unmanaged code.
I found the "Detach All" option in the Debug menu, however it is disabled (grayed out).

Open the Processes window (Debug->Windows->Processes), right-click the process, select "Detach Process".

You cannot detach a debugger from a process if you are debugging in mixed mode.
Make sure you are debugging either in managed or native mode while attaching to the process: either make sure "Enable native code debugging" or "Native Code" is unchecked in your project options, or start the program without debugging, choose "Attach to Process", and select only Managed or only Native.

Debug -> Detach All
Works great on my VS2008 and VS2010.

Related

How to force Visual Studio to use the .NET4.x debugger even when the startup program is .NET2

OK, here's the scenario: I am developing a COM component in C# and C++. I have recently upgraded the development from .NET2 in VS2008 to .NET4 in VS2010. Testing involves running a separate application. The test program has a "Go" button which loads the COM component and calls its functions. However the test program runs under .NET2.
Now, since the upgrade to .NET4 I can no longer simply put the path of the test program into the "Start external program" field of the Debug properties page and press start. If I do this no symbols are loaded for my component, it doesn't appear in the modules list and can't be debugged. After a lot of puzzling I finally discovered that I now need to start the external program first. I then open the "Attach to Process" dialog. When I select the test program's process the "Attach to:" box shows "Automatic: Managed (V3.5,v3.0,v2.0) code". I have to press the Select button and specifically select "Managed v4.5, v4.0" before attaching. I then press the Go button on the test program and everything works.
So here's the question: How do I get Visual Studio to start the .NET4.x debugger by default when I press Start in VS, so that I don't have to go through this whole Attach To Process malarkey every time (and so that those who come after me don't have the same problem)?

VS 2008 Attach to process disabled

I have used the attach to process feature of visual studio a number of times. However now when i try to attach to a process (dll) the Attach button is disabled. However if i select any other process except the managed one the Attach button is enabled! My problem is closely related to the problem described at the link below
VS attaching to process disabled
A picture of the dialog is attached.
This is almost certainly 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.
Found the solution to the problem
How to step into C/C++ DLL from C# application while debugging
http://msdn.microsoft.com/en-us/library/605a12zt%28v=VS.90%29.aspx

detach one process from visual studio debugger

My question is somewhat similar to this
"How to stop debugging (or detach process) without stopping the process?"
but i want to detach from one process.
for instance, I have a windows form app which i also attach to a windows service. I want to detach from only service (detach all will remove debugging from all executions and hence i won't be able to debug other application).
P.S: If possible please mention for visual studio 2008 and 2010.
In the Processes window (Debug -> Windows -> Processes), right-click on the name of the process you want to detach, and on the shortcut menu, click Detach Process.
Just wanted to share that the shortcut key combo (in VS2013) is Ctrl+Alt+Z to bring up the Process window. The window will only pop up if there is at least one process attached.
If you have Visual Studio Express, there is no Processes window and I did not realized how to detach only one process.
If you are doing Mixed Mode debugging then neither the Debug > Detach All option nor detaching as mentioned in Centro's answer in this thread would work.
I see the Debug > Detach All option or Detach Process option in Debug > Windows > Processes dialog, when I am debugging in Native only or Managed only mode.
I have tested this on Visual Studio 2005 at least for now.
Reference: https://developercommunity.visualstudio.com/t/cannot-detach-from-process-the-debugdetach-all-opt/225642

Debugging in Visual Studio

what is the difference between start Debugging and Start Without Debugging in Visual Studio while running a program ?
The first option starts the program under the control of Visual Studio's debugger. The second option starts the program stand-alone. Some of the practical differences while debugging a process are:
You can pause, resume, stop and restart the debugged process from Visual Studio.
Breakpoints defined in the code will be active for a debugged process, and the debugger will pause the process and show a stack trace whenever the process hits one of them.
You cannot exit Visual Studio without stopping the debugged process.
When a debugged console process exits, it will display a termination message until you press a key. This allows you to inspect the output of a just-ended process without having the console window immediately disappear on you.
The former attaches the debugger, the latter does not. You use the latter if you want to run in the same way an end user would.
the answer seems obvious, especially if you just try it :)
"Start without debugging" starts your app but doesn't attach visual studio as the debugger. "Start debugging" starts your app, with visual studio attached as the debugger.

How do I keep the development web server (Cassini) running in Visual Studio 2008?

I'm using Visual Studio 2008 to develop ASP.NET applications. Currently I'm debugging with running on IIS. I would like to switch to the development web server (Cassini) for debugging, so that I can use features like edit and continue. The reason that I'm not, is because the development web server only starts up when you are in debug mode. Is there any way to keep it running all the time, and just have Visual Studio attach to the existing server process like it does with IIS?
Rihan is partially correct...
In your Project Property page, Web tab: Enable Edit and Continue
If checked - The Development server will close when the app (not VS) stops.
If unchecked - Development server keeps running
You can also start your cassini server from the command line which takes alot of pain out of the whole "debug" effort...
Check out a good snippet here on how to do this: https://thoughtjelly.wordpress.com/2009/05/13/launch-cassini-from-the-command-line/
Once started, the built-in web server continues executing even when you stop debugging, as long as your VS2008 project is still open. Just start up the debugger when you want to start debugging again. I typically have another browser window open and interact with the built-in web server from there instead of the browser window that it opens so I can keep working with the application in the same state even after turning off the debugger (which closes the opened browser window).
I'm running VS2008 on Windows XP SP3.
The simplest way I have found to acheive that is by launching the debugger as normal. Then in Visual Studio goto the Debug menu, and select detach all. It detaches from the Cassini web engine, but it does not shut it down, as it does when stopping debugging.
I am quite sure you are know that there is command line swithces that you can you use to launch the cassini engine, but my guess is you are looking for something slightly easier.
Detaching does not close the browser window that visual studio launched, and if you do close that spesific web window then it will stop debugging.
I am running VS 2008 SP1 on Vista 64x SP1 without IIS.
Hope it helps
Rihan Meij
I have 3 web sites, with Single sign on between each site so I need to start all 3 with attach to process. However, there was no process to attach the debugger to, and whenever I started a project with F5 then stop it, the visual studio web server closed.
The Enable Edit and Continue option didn't change anything.
So to start the web server and keep it running so that you can attach the web project to the process, I simply did a "view in Browser" (ctrl+shift+W). This started the server process but not the project nor the debugger. I could then attach to process easily.
In Visual Studio 2015 you do this by going to Tools > Options > Debugging > General and unchecking the "Enable Edit and Continue" option:

Resources