Click here to Skip to main content
15,881,852 members
Articles / Desktop Programming / MFC
Tip/Trick

Multiple Projects in One Solution

Rate me:
Please Sign up or sign in to vote.
1.00/5 (2 votes)
22 Apr 2013GPL32 min read 42.2K   1   6
Multiple Projects in One Solution

Image 1

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.

Background

I needed 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.

two_solution_dialog

Ok that and complete any selections you may need. The solution explorer should look something like this.

solution_explorer_1

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.

solution_explorer_2

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.

select_startup.jpb

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.

History

Original post: 22 April 2013  

23 April 2013, first image was incorrect, edited title.  

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow Can i Call Page From Second Project Pin
Kashif Ali3-Jul-18 1:01
Kashif Ali3-Jul-18 1:01 
GeneralMy vote of 1 Pin
Manish K. Agarwal25-Apr-13 23:26
Manish K. Agarwal25-Apr-13 23:26 
General[My vote of 1] are you serious?!.. Pin
Seishin#23-Apr-13 0:43
Seishin#23-Apr-13 0:43 
GeneralRe: [My vote of 1] are you serious?!.. Pin
bkelly1326-May-13 7:22
bkelly1326-May-13 7:22 
To Manish and Seishin,
You are correct, by itself, this tip is a bit weak.
However, I needed to simplify a major article and extract two subjects that were important, but cluttering the main theme.
That main article is here: Asyncsocket Part 3: The Server[^]

Hopefully that purpose provides a bit of justification.
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/

BugFirst Image Missing Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)22-Apr-13 20:26
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)22-Apr-13 20:26 
AnswerRe: First Image Missing Pin
Clifford Nelson23-Apr-13 5:14
Clifford Nelson23-Apr-13 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.