Does VS2010 support multi-attach? - visual-studio

When I hit F5 to debug an application, there are usually more moving parts in terms of processes than the one process associaed with the project that is considered the "startup application". For example, a web application makes calls to another (isolated) web application that hosts WCF web services. Both apps are in the same solution, both share/reference the same assemblies (also in the same solution), and both need to be debugged at the same time.
I've given up on Visual Studio 2008 for obvious reasons, and I already use the Debugger menu to manually attach and I even sometimes write System.Diagnostics.Debugger.Attach() at startup but hate doing that; is it possible to configure Visual Studio 2010 to late-attach to multiple processes, i.e. multiple projects in the solution as they are started?
I understand that it's "difficult" for Visual Studio to know how to attach to multiple processes particularly if the secondary processes are "spawned" by the first process--Visual Studio won't have the PID of the secondary process up front.
However, if it's too "difficult" for Microsoft to create a one-size-fits-all debugger attachment implementation, it would be ideal if in the same concept as "pre-build" and "post-build" shell commands could also be applied to pre-debug and post-debug invocation macros and the System.Diagnostics.Debugger modified so that we can write a line or two of code that can cleanly late-attach to another process while in runtime, without a dialog. Or something.

Are you debugging your services through IIS or Cassini? If you are starting the services directly in VisualStudio, you can in fact start multiple applications/services at the same time.
I don't have access to VS2010 at the moment, but in VS2005, I right-click on the solution in Solution Explorer and choose Properties. Under Common Properties select the Startup Project category. By default it will be set as "Single startup project." Change this to "Multiple startup projects" and set the Action for each project that you want to run. After this, pressing F5 will start all of the projects specified.

Related

Debugging two projects in two instances of Visual Studio at the same time

When I try to open two projects in two different instances of Visual Studio and run both of them locally in debug mode at the same time (say, a web application and the backend WebService that it uses) I get the error "Unable to start debugging on the web server. A debugger is already attached"
No one else in the office is able to do it either, except for one person, who can't figure out why it only works for him. The virtual directories in my computer's IIS seem to be set up the same way as his (I don't know about the settings).
I was also able to debug from two instances of VS at once at my previous job, so something about the setup here must be different.
I figured it out. Each project needs to be set to a different Application Pool. Found the answer here.
Since the same AppPool was being used by both the Web Application and Web Service, the same process hosted both. That is why as I had already attached the process in one instance of Visual Studio, I could not attach it in the second instance of Visual Studio.
Changing the AppPool had the effect of both being hosted in different host processes and hence they could now be debugged using different instances of Visual Studio.

Specify which project to debug when attaching to process

How can I specify which project in the solution to debug when attaching to a process, preventing Visual Studio 2010 from starting all other web-based projects in the solution, too?
I hate it that every time I attach to a process to debug one web project in the solution, it automatically builds and starts running all other web projects; can I prevent that without having to take them in their own solutions?
I think you're confusing the terms a bit here. It sounds like when you say "Attaching to Process" you really mean "Start debugging by pressing F5", is that the case? If so, to control which projects start up when you hit F5, right click your solution in Solution Explorer, and go to Common Properties->StartUp Porjects, and select the option you want.

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.

Running two projects at once in Visual Studio 2010 - do not want

You may think this question is the exact duplicate of Running two projects at once in Visual Studio. Not really, it is the exact opposite.
I have a VS 2010 solution with two MVC3 projects. I've already configured the solution with a single startup project. However, each time I run it, VS spawns two servers with the two MVC applications (and one does not have direct dependency on the other).
So, how do I get rid of such behavior?
Click on the project you don't want to start up, go to the Properties tab, and change 'Always start when debugging' to False.

Can I to run several projects in one solution for debugging in VS 2010 Ultimate?

I have a solution consisting of several executable projects (formally speaking server and its clients). But start-up project is only one (server) but I need to debug and clients too. Now I start their (clients) from folder from shell explorer. Is there any solution for this?
Yes you have to set up your solution to start multiple solutions.
Right-Click on your solution and choose "Set StartUp Projects...".
Then in the Dialog check "Multiple startup projects" and choose the action of those you want to start to "Start" (with debuging) or "Start without debuging".
Click Ok - done.
Now just hit F5 and all your selected projects should fire up and run.
I'm not sure about running all the projects at the same time, but there are two things that spring to mind:
Open Visual Studio twice. Run the server from one, and the client from the other, or
Continue to run the client from the shell, but attach the debugger to the client. Just go to the Debug menu, and select 'Attach to Process'.

Resources