Attach to Visual Studio process by name - visual-studio

For the development I do, I often need to attach to a running process by name (usually a windows service running under a different user account). It is tedious to do:
Debug
Attach to Process...
Select Attach To to switch between Native and Managed code
(we use both in the same process so it's not set to automatic)
Scroll down to find it in the list
Hit Attach button
Agree to the confirmation to debug a windows service
Since it's always the same process, ideally I would like 2 buttons (macros?) on a custom toolbar. One that attaches for managed debugging and another that attaches for native debugging. In both cases, the process name is built into the macro.
Can someone point me to the right resources/documentation to set something like that up?

A Visual Studio macro that you can customize for your process name:
Attach the VS Debugger to IIS’s Worker Process in a single keystroke.
Debug Attach Manager 2012 extension for VS 2012 that "provides extended abilities to attach Visual Studio debuger to web application pools, windows services and other processes."

Related

How to debug two web applications/services on IIS from within Visual Studio?

In Visual Studio 2010,
I want to debug two web applications running on IIS at the same time.
When debugging the first application it is ok. But when starting to debug the second application and first program is still in debug mode, Visual Studio prompts:
unable to start debugging on the web server. a debugger is already
attached
How can I solve this problem?
To summarize, one has to set different application pools in IIS for the two applications to debug.
Here is a rough instruction, given that both applications have been deployed to IIS once within Visual Studio.
Open the Internet Information Services (IIS) Manager
Click Application Pools on the left pane
On the right pane add another integrated application pool, let's name it Second ASP.NET 4.0 Integrated
For one application, open the Advanced Settings...
In the properties view finally select Second ASP.NET 4.0 Integrated as the application pool
This way the applications should be debuggable in parallel because each Application Pool spawns a new operating system process to which a separate debugger can be attached.
A windows process can only have one debugger attached to it at a given time. If you get that message it means that you're attempting to debug the same process twice which won't work. But that also means you should be able to debug both web applications in the instance of Visual Studio that's already attached. It may require a few extra steps though to get it to acknowledge the other code
Disable "Just My Code" (Tools -> Options -> Debugger, uncheck "Enable Just My Code"
You may need to manually load symbols for the other web application through the modules window (Debugger -> Windows -> Modules)
After that though (second step may not be necessary) you should be able to set break points in both web applications and otherwise debug them.

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

windows service running from Visual Studio 2010. Anyway to impersonate some user for LogOn

When a windows service is setup its run under a default network service logon. If I am debugging a windows service project from Visual Stduio, what logon credentials does it use? Also is there anyway to impersonate some other credentials when debugging this service from visual studio 2010?
Hi there Silverlight Student,
You can easily debug a Windows service using Visual Studio and there are multiple ways to do it.
One way you can do it is start the windows service, and then go to the debug menu in visual studio, and then choose Attach To Process. You'll find your service in the list, and double click on that. Then you can trap break points, trace, and everything in the debugger. Depending on how you start the process, that will affect the user account it runs under.
A second way, is you can set your service so it can also be started by command line and even open up a console window. I explain how to do that, with sample code here:
C# Windows Service: The service did not respond to the start
If you want to have the service run in a particular user context, you can go into the Windows Service Control Manager and configure what user your service runs as, then start it from there, and then use the attach to process approach to hook on using the debugger.
David

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

Attach existing VS.NET 2008 instance that's already debugging as JIT debugger

Is it possible to configure the VS.NET 2008 "Just-In-Time" Debugger dialog to show an existing instance of Visual Studio that's already attached to another process?
The scenario I have is an NUnit unit test that runs another process. When I'm debugging the unit test I want to automatically launch the debugger for the child process it runs as well. I pass a special parameter to the child process and the child calls Debugger.Launch(), which is all fine, but when the JIT debug dialog comes up it doesn't list the existing VS.NET instance - I can only open a new instance, which is quite inconvenient.
A debugger that's attached to another process, cannot attach to a secondary process. I think it is possible to have a debugger attached to multiple programs (you can debug multiple websites that are part of the same solution for instance).
Also, you cannot attach more than a single debugger to each process.

Resources