contains 2 solution files


Well-known member
Nov 13, 2012
Programming Experience
In a C# 2008 application that I amn working with there are two different solution files that are connected together. There is a smaller solution file called 'sample'. There is another solution file I will call the 'main' solution file. The 'main' solution file contains 3 project files plus the other solution file called sample.
Due to the statement I listed above with the 2 different solution files, I have the following questions:
1. When I am working with the 'main' solution file, I was orginally assuming that the 'sample' project code that I am looking at was the code in the 'sample' solution file. However when I was debugging this application this week, I found out that this is not true since the code is different. I found out that the code is different when looking at the auto generated code setup by the linq to sql designer. I was 'stepping through code' and I found out there was a difference.
Thus is there a way to make the 'sample' project code file be the same that is in the 'main' project file? If so, how would you accomplish this goal?
2. I need to check this code into version control software called team server foundation or subversion. I want to make certain that only the code in the 'sample' project folder is checked into the version control software. I do not want the 'extra' sample project file that is appears in the 'main' solution file to appear. Can you tell me how you would solve this issue?
If you have created two solutions then, in one of the solutions, you can add an existing project and select a project from the other solution. In that case the IDE will NOT create copy of the project. It will refer to the original project in place. As such, any changes you make to the project through one solution will be reflected through the other solution. You can test this for yourself quite easily. I don't have VS 2008 installed but I'm 99.9999% sure that this functionality hasn't changed from that version and here's what I did to test it in VS 2010:

1. Created a new solution containing a Console Application project.
2. Closed that solution and created another new solution also containing a Console Application project.
3. In that second solution I added Console.WriteLine and Console.ReadLine calls to the Main method.
4. Ran the project in the second solution to confirm that the text I passed to WriteLine was displayed.
5. Closed the second solution and reopened the first.
6. In the Solution Explorer, right-clicked the solution and selected Add -> Existing Project and selected the Console Application project from the second solution.
7. Made that second project the startup project for the solution.
8. Ran the project to confirm that the same text was displayed as before.
9. Changed the text that was passed to WriteLine in the second project.
10. Ran the project again to confirm that the new text was displayed.
11. Closed the first solution and reopened the second solution.
12. Ran the project to confirm that the new text was displayed.
13. Changed the text passed to WriteLine.
14. Ran the project to confirm that the second new text was displayed.
15. Closed the second solution and reopened the first solution.
16. Ran the project to confirm that the second new text was displayed.

These steps prove that adding an existing project to a solution does not create a copy but rather refers to project in place. You can prove this further by opening the first SLN file in Notepad and reading the location of the second project. In short, if you have two copies of something somewhere then it's because you have created two copies.
Here's the part of the SLN file for the first solution from above that refers to the project locations after adding the existing project from the second solution:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{4CE68359-A02C-4C74-B973-A2E7C7746011}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication2", "..\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.csproj", "{2442A7B8-F1A5-4E80-B11F-5216D395B279}"
As you can see, the second project is referred to in its original location.
I am wondering if I created 2 copies of the code. When I am in the 'sample' solution, I made changes to the code. When I am in the main solution and I look at the sample project code, the code looks different. When I was in the sample solution, I made changes to the code. When I was in the main solution and was accessing the sample project, I made changes there also. Thus can you tell me if I was m aking changes to the same project file by using the 2 different solution files?
Top Bottom