I have a web service which runs in a app pool in IIS. Whenever I try to debug this web service I attach it to the visual studio debugger. However, the problem is there are multiple w3wp.exe (which hosts the web service) and I don't know which one to attach to. As a workaround, I first open the task manager (which has process command line as one of the column) check which of the mutiple w3wp.exe is hosting my app pool, note down its PID and then attach to the process with that PID from visual studio. Is there any better way to do this? Can I view the w3wp.exe command line parameters from visual studio 'attach to process' window itself? I am using visual studio 2010.
For Window 2008/Vista/7 (IIS 7.0/7.5)
IIS 7.0/7.5 shipped with a new utility called AppCmd which serve as a command line server management utility.
This tool located in %systemroot%\system32\inetsrv\AppCmd.exe
To list current worker process Id’s along with it’s corresponding site use
the below command
C:\Windows\System32\inetsrv>appcmd list wp
Once you know your application worker process Id, you select the correct worker process from “Attach to Process” dialog on Visual Studio
Hope it does help.
Related
we currently have 2 developers working on 2 different websites, on the same server.
when an error occurs in one of the web applications, that debug option pops up for the wrong developer. how do we specify what VS instance is to be used for which w3wp debugger process attached?
Here are a couple of options sorted from best to worst...
Run Visual Studio locally on the developer's computers so this isn't a problem.
On the server, use Visual Studio's web server instead of IIS. This gives each user an automatically created local process that can be debugged.
If you must use IIS, configure each application in IIS so that they run in their own application pools. Each application pool gets its own w3wp process so your Visual Studio instances can attach to their own process.
I need to know which ID process I need to attach to debug my website remotely. My website is hosted on a virtual machine with Windows Server 2003 and I am debugging with Visual Studio 2010.
W3WP process was the name expected on my task manager, I think I am missing something.
Can anyone advice me on this?
These are all the process with that start with 'w'
Also I tried to add dllhost.exe, but when I put a breakpoint it says that the table symbols is not loading properly. Do I need to attach a .pdb file?
To see the IIS process running, you need to open a browser and search the url that is publish. Otherwise the process will not run and you will never see it on the Task Manager. This is different for Windows Server 2008, there the IIS process is running all the time.
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."
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
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: