Running two projects at once in Visual Studio - visual-studio

I created a solution in Visual C# 2010 Express that contains two projects: one is the client, the other is the server. I would like to debug both at the same time, but I can only seem to run one of the projects during debugging.
Is there a way to run both at once?

Go to Solution properties → Common Properties → Startup Project and select Multiple startup projects.

Max has the best solution for when you always want to start both projects, but you can also right click a project and choose menu Debug → Start New Instance.
This is an option when you only occasionally need to start the second project or when you need to delay the start of the second project (maybe the server needs to get up and running before the client tries to connect, or something).

Related

Convenient way to launch one of several project in Visual Studio

My solution contain about 50 projects
and there are 2 projects I usually launch for debugging (one is for web GUI and another one is for buisness logic).
Often I launch/debug just one of those two projects. but sometimes I need them both started under debugger.
Currently I do so: I write name of a project in the Solution Explorer's filter input, then "Debug - Start new instance"
My question is: is there a (more) convenient way to launch these projects from Visual Studio (2019)?
I know about the multiple startup projects, but I rarely need to launch both project.

Specify which emulator to use in Visual Studio when solution has multiple startup projects

I have a solution that contains a Xamarin forms app and a WebAPI 2 service that provides the back-end to that app.
When I set the solution to have a single startup project, I can choose which device/emulator the project should be deployed to using a dropdown in the toolbar, but when I select multiple start up projects I can no longer choose the emulator/device (the drop down list of emulators disappears). Because there is no deployment target the build then fails.
Is there another way to specify which emulator/device the Android project should launch on (maybe in code, e.g. in the project file?).
I've looked into this some time ago but didn't find any real solution other than just opening the solution twice and running the Web API and app with a single startup project.
Most of the time, I just run one project without debugging (ctrl+F5).

Multiple "Set StartUp Projects" Configurations

I have a big solution and for debugging purposes I have to start many Projects by using "Set StartUp Projects" Feature of Visual Studio 2012. However often I need to change what projects I need to start (Sometimes is Project A,B,C, sometimes Project B,C,D etc.)
Does someone knows such an Extension?
Take a look at the SwitchStartupProject extension. (I'm the author)
Since version 2.0, it allows you to configure multiple multi-project startup configurations. You can switch between the configurations with a toolbar dropdown box:
To configure two configurations (A, B, C) and (B, C, D):
Install the extension (you might need to restart VS)
A new Startup Project dropdown box appears to the right of the Start button.
Click on it and choose Configure...
Select single-project list mode None (to hide the single project items from the dropdown)
Add two configurations and name them ABC and BCD
Add multiple projects to each of the configurations
Choose the order in which the projects will be started
Note: Unlike the Visual Studio startup projects dialog, the extension does not allow you to choose start without debugging for a project. So all projects that you add to a multi-project startup configuration are started with debugging.

Run multiple instances with one click in Visual Studio

I wonder if I can run multiple instances (right now two instances) of my application in debug mode by doing a simple click or set a key for that...
Not many people seem to know this, but this is perfectly possible, though I admit it's not very obvious.
Here's what you do:
suppose your current project is A, and it's output is c:\bin\my.exe
add an empty project to the solution for A, call it 'Dummy'
under Dummy's Project Properties->Debugging set the Command to point c:\bin\my.exe
under Solution Properties->Configuration Manager, uncheck all builds of the Dummy project so VS won't try to build it (building an empty project fails)
under Solution Properties->Startup Project, select Multiple Startup Projects and set the Action for both A and Dummy to Start
now hit F5 and your exe will be launched twice, each under a seperate debugging instance. (as you will be able to see in the Debug->View->Processes window)
You can use "Multiple Startup Projects" feature, but avoid creating dummy projects by hand: just add your debuggee executable into the solution directly:
Solution > Add existing project > Path to .exe
If you neeed several instances, Visual Studio won't allow you to add the same executable twice, but adding a symlink to it with another name works as expected.
MSDN: How to: Debug an Executable Not Part of a Visual Studio Solution
Is Visual Studio 2013 this is even easier!
Project-> Properties -> Debug -> check "Start external program" and click the ... button, navigate to your .exe of the other program.
Then Make sure in your Solution -> Properties -> MultipleStartup Projects that it's checked.
You can run two instances of your application from where it is built; example: d:\test\bin\debug\app.exe and attach both instances to the Visual Studio 2010 debugger.

Visual Studio debugging is not attaching to WebDev.WebServer.EXE

I have a solution with many projects. On Debug, I have three web projects that I want to start up on their own Cassini ASP.NET web development servers. In the solution properties → Common Properties → Startup Project, I have multiple startup projects chosen with the three web applications' Action set to Start. All three web development servers start, and all three web pages load.
However, Visual Studio is only attaching to two of the WebDev.WebServer.EXE processes. I have to manually go attach to the third process in order to debug it with the debugger.
This behavior just started happening, and I'm at a loss as to how to troubleshoot this.
Also to note, I have stopped and restarted the development servers several times with no change in behavior. Also, when attaching to the process manually, I see that the Type property of the two automatically attached WebDev.WebServer.EXE processes is Managed, while the Type property of the unattached WebDev.WebServer.EXE process is TSQL, Managed, x86. When looking at the project's properties, however, I am targeting AnyCPU, and do NOT have SQL Server debugging enabled.
The two projects that attach correctly are C# web applications.
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
The project that is not attaching correctly is a VB.NET web application.
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
The behavior is the same on another workstation. So odds are that it's not a machine-specific problem.
This might be a shot in the dark, but I would look at the csproj files, to see if the one that isn't working has any obvious differences. In particular, I would look for a <ProjectTypeGuids> element. Anything that relates to web-hosting is of interest too, of course; so anything under:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
(or similar, depending on your flavor of project; compare between the 3 for anything that looks out of place)
Right click on the main solution -> Properties -> Common Properties -> Start Up Project ->
Make sure it's set to "Multiple startup projects" and all are set to "Start" instead of none or start without debugging.
Also double check each projects .user file and make sure AlwaysStartWebServerOnDebug
is set to true along with any other debugging options.
I set multiple startup projects and choose each of the web applications in the properties of the solution (Right click the solution in Solution Explorer → Properties).
Is the third project an IIS web project (set in properties)? We have numerous IIS projects that run together and we don't have any issues debugging.
Try solution → Properties → Configuration Properties → Configuration and see what projects get build and when.
Not sure what the problem might be, but when I've had problems with complex projects before I've found it helps to look at the .vbproj or .csproj files directly.
Have you tried creating a new VB.NET project and simply copying over the files from the non-working project?
I'd also try adding a 4th, very simple C# web application project to see if perhaps 3 is some sort of magic number for your configuration (though I'm currently working on a solution with more than 3 and have no problems debugging). You could do the same with a simple VB.NET web application - you'll know then whether it's a problem with webserver #3, VB.NET in general, or your specific project.
Is debugging enabled in the Web.config file of the web application? Is it set to Debug mode when you start it in Visual Studio?

Resources