Iâ€™ve already blogged about the creation of a macro that permits you to attach to IIS worker process pressing a key combination. This approach does not work if you have multiple w3wp.exe processes that are actually running into your machine, because the macro only attach to the very first of them.
A simple and stupid solution is to attach to every w3wp.exe processes that is actually running in the system :), it is somewhat a â€œpatchâ€ solution, but it is really easy to implement, because it requires only a minor modification of the code generated by the Macro Recorder.
The change is in lines 8-13, in the first version I use the Item Index property of the EnvDTE.Processes object to grab the first instance of the process named w3wp.exe, in this smarter version I iterate through each process, and attach to every process that ends with the string w3wp.exe. With this little modification Iâ€™m able to attach to every IIS process, a capability that is useful when you are debugging multiple sites / services and you need to use multiple worker processes.