Programming Tip for Visual Studio
When creating multiple executables that are closely related, it can be very
beneficial to have several projects within one solution.
this when writing my Server and Client TCP applications. The Server was to
be run on one computer while the Client runs on another. However, they are
so inter-dependent on each other it was helpful to have both in the same solution.
I was unable to find clear instructions so I wrote this tip. Here is a
link to the article and project that prompted this need:
My TCP/IP Article
Using the Tip
Start the project to create a solution and a project in the usual manner, but stop
with the New Project dialog displayed. I have used C++ with MFC but I suspect this
will work for all languages.
Normally at this stage, I fill in the [Project]Name and the solution name is automatically
filled in. Then I click OK and go on. This time, after entering the [Project]Name,
enter a solution name. For this example, the [Project]Name is First_Project and
the solution name is Two_Project_Solution.
Ok that and complete any selections you may need. The solution explorer should
look something like this.
That should all be familiar. In the above image I have jumped ahead a bit and
selected the solution rather than the project just to highlight it.
The next step is to create the second project. Right click on the solution and
select Add then New Project. The dialog field Location defaults
to the location of the current project so just leave that field alone. Go
through the same steps as for the first project and click the final OK.
My example named the second project Second_Project.
In the below image I have closed (un-expanded) the two projects so just the
project names are shown.
When writing your code, nothing changes. Select the solution and go to work.
The next change is for running your solution. Right click on the Solution and
select Set Startup Projects. Here is the dialog.
The default for me was Single startup project. In the image I have
changed it to Multiple startup projects and opened the drop down box
for the first project to show the options. When working my TCP/IP code, I would
set one to Start and the other to Start without debugging. Start
obviously implies Start with debugging.
That is it. Happy coding.
Original post: 22 April 2013
23 April 2013, first image was incorrect, edited title.