21

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?

rmoestl
  • 3,059
  • 5
  • 24
  • 38
Morteza
  • 2,378
  • 5
  • 26
  • 37
  • Why do you need to do that? What are you working on? Provide more information please. – LihO Feb 04 '12 at 12:46
  • I have 2 web application, first app get data from second app by JsonRPC. I want trace my function – Morteza Feb 04 '12 at 13:16
  • But do you really need to debug both applications? It's not very common to do so. I guess it's enough to debug only one of them while second is running. – LihO Feb 04 '12 at 13:18
  • Start two instances of visual studio ? – wal Feb 04 '12 at 13:27
  • I resolve my problem. I Set different application polls for two application in iis. and now I can debug both Application in same time. – Morteza Feb 04 '12 at 13:41
  • 1
    You can sort of debug multiple applications using the same application pool at once. If you open a file(s) from the other application inside Visual Studio while debugging the first application, you can set break points and debug that code. As long as the two projects are "open" in Visual Studio they can be debugged I think, such as if the two projects are part of the same solution. – Anthony McGrath Sep 20 '18 at 20:42

2 Answers2

40

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.

  1. Open the Internet Information Services (IIS) Manager
  2. Click Application Pools on the left pane
  3. On the right pane add another integrated application pool, let's name it Second ASP.NET 4.0 Integrated
  4. For one application, open the Advanced Settings...
  5. 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.

rmoestl
  • 3,059
  • 5
  • 24
  • 38
  • Just a note, setting start mode to "always running" can be helpful. I had mine to set to "on demand" and there was no additional worker process to attach to because it was only being started on demand. – Hunter Nelson Jul 19 '18 at 19:32
5

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.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454