Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
I had lost my Microsoft Visual Studio Solution (.sln) file from my project in VS2008.

How can I reproduce?
Updated 6-Jul-11 21:16pm
Dalek Dave 7-Jul-11 3:16am    
Edited for Grammar and Readability.

Open VS2008 > New > Project > Other Project Types > Visual Studio Solutions. Then select Blank Solution from Templates Tab. Copy your project folder and paste it to new created solution project folder, at the location where (.sln) files of new project saved. And then right click on your created solution in Solution Explorer, select Add Existing Project and browse to your new pasted project folder and select file having extension (.csproj).

You have successfully found your lost (.sln) file with your project.
Share this answer
Sergey Alexandrovich Kryukov 7-Jul-11 2:28am    
Correct and short, my 5. Please see my more detailed solution.
[no name] 7-Jul-11 2:42am    
Thanks SAKryukov, i have read yours, Good explanation. Like it. my 5 too.
Sergey Alexandrovich Kryukov 7-Jul-11 5:27am    
Thank you.
In fact, one of you voted 1, perhaps by mistake. Would you check it up?
Dalek Dave 7-Jul-11 3:16am    
Spot on, gets a 5.
[no name] 7-Jul-11 3:37am    
To the Mark. 5 too.
This is not a problem at all. There is so little information in this file compared to anything else, that you will re-created it very quickly.

Simply create an empty solution with Visual Studio. Check up if the file is placed in right directory. The perfect location of the SLN is where all the project files (*.*proj, for example, *.csproj) you need to have under this solution will go directory structure below the directory where your SLN file is placed. If you saved the new SLN file in a wrong place (which is very easy to misplace), don't save it again. It's easier to exit Visual Studio and move the SLN file in proper location manually. After that, click on this file to load Visual Studio again.

You solution file is created and placed in a right place. Now you need to add all project files to it. You may want to refine your solution structure down the road using "Solution Explorer" => you solution node => "Add" => "New Solution Folder". The solution folders will not alter the directory structure of your projects and won't affect build or run-time of your projects. Add the projects one by one using "Solution Explorer" => you solution node => "Add" => "Existing Project".

Final step: check up project dependencies via Main Menu => Project => "Project Dependencies…". This step is not needed is your projects referenced each other using project references (recommended), when the references were added using "Add reference" => "Projects". If you made the references this way, the project dependencies will be set automatically based on referencing relationships, which are recorded in projects, not in the solution file.

That's it. All other information on project structure, options, etc. is kept in project files *.*proj. Hope you did not loose them. :-)

Main recommendation: stop doing any development without Revision Control System! Those systems are light-weight, free of charge and easy to use. Don't risk your code asserts.

See the following discussion: Revision control systems, which to choose from?[^].

Share this answer
Toniyo Jackson 7-Jul-11 2:30am    
Perfect. My 5
Sergey Alexandrovich Kryukov 7-Jul-11 2:37am    
Thank you, Toniyo.
[no name] 7-Jul-11 3:36am    
Valid point SA. My 5 too.
Sergey Alexandrovich Kryukov 7-Jul-11 5:25am    
Thank you, Ramalinga.
[no name] 7-Jul-11 23:48pm    
It's my pleasure.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900