Why double-clicking on an .SLN file doesn't always launch Visual Studio

Published 13 February 08 08:32 PM | andarno 

Well this is my first post as a member of the Visual Studio Platform & Ecosystem team.  My second full day on the job, and I've found some less-than-ideal areas of Visual Studio that I'm eager to improve for myself and for you, our customers.  How exciting.  I'll do my best to post to my blog whenever I run across some unexpected scenario that is likely to hit customers and how to work around it.

So on to the first scenario...

Scenario

You have Visual Studio 2008 installed, but some Visual Studio Solution files (.sln) don't open when you double-click on them.  In fact, nothing happens.

Analysis

When you double-click on a .sln file, a small program called vslauncher.exe is called with the path to your .sln file as its first argument.  The job of vslauncher.exe is to read enough of your .sln file to determine which version of Visual Studio to use to open your file.  Since you may have several versions of Visual Studio installed (VS2003, 2005, 2008, Express SKUs, etc.) you probably want to open the solution with the same copy of Visual Studio that you used to create it.

The issue comes up when your .sln file signature (the first two lines of your file) don't match any known release of Visual Studio.  Visual Studio 2008 .sln files typically start with these two lines:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008

But suppose you have a .sln file that was created with a Visual Studio 2008 beta.  You might have a .sln file that starts with this instead:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio Codename Orcas

When Visual Studio 2008 RTM reads this, it doesn't recognize its earlier beta versions' solution file signatures and just quits.  It would be nice if a user-friendly message telling what happened would pop up.  Alas, it does not.

Workaround

Simply open your .sln file in Notepad and change "Codename Orcas" to "2008" on the second line. 

[Update 2/16/08] This blog was featured on Channel 9, and as a result a couple of people wrote up a PowerShell script and a C# program to automate updating all your .sln files at once.  Very cool.

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# DanielMoth said on February 14, 2008 2:29 AM:

Glad you found a new home Andrew.

Thought I'd add that the issue you describe is specific to Beta 1 of VS2008 (not even Beta 2), so this goes waaay back... (to July looking at my respective blog post ;-)

# William Stacey said on February 16, 2008 2:31 AM:

Here is a *.sln fix. A 1-liner in PowerShell:

dir . -r *.sln | %{$t=cat $_.fullname;$t -replace "Codename Orcas","2008" > $_}

Naturally, should always do a backup before such global replacements:

dir . -r *.sln | %{copy $_ ($_.fullname + ".bak")}

# George P. said on April 6, 2008 6:22 PM:

It may also fail to start if VS is set to run in admin mode.

# shachar said on May 12, 2008 11:21 AM:

Hi All,

Can you help me in adding files dir to sln ?

i wonder if there is a script or other possability when adding dir or files to a working project if it can be add automaticlly and not manually when opening the sln file

10x

Shachar

# Whitney said on October 15, 2008 9:40 AM:

Also, it appears the solution must be UTF8 encoded.

# Dale said on June 21, 2009 12:36 AM:

This issue is not just for versions like Orcas.  I have VS2008 solutions with the first lines exactly as your post says and I can successfully open and save them using File->Open but double-clicking in Vista does not open VS2008.  Since double-clicking is a standard Windows functionality I find it stunning that the Windows group did not overrule the VS2008 group's decision to break from the usability standard.  Programatic security elevation is a standard and supported feature in Vista so all of this security stuff you're quoting is just hype.  This is simply a bad decision but, according to this Connect issue, this is by design.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=263221

# Paolo Marani said on September 25, 2009 9:46 AM:

Whitney, you saved my day !!!

I have manually edited my solution .sln file using a text editor, and since that time the double-click on this solution only was not opening visual studio anymore.

The culprit was the encoding of the .sln file. If you save back to disk ensuring it's coded in UFT-8 it is magically fixed!

Thank you so much.

# Marcel Popescu said on October 14, 2009 4:16 AM:

Thank you Whitney... I was generating .sln files and mine, though identical in content to others, would not open on double-click; turned out to be a matter of encoding - as soon as I re-saved them in Notepad with UTF-8, it worked.

# Ben de Vaal said on October 29, 2009 5:16 AM:

Great post, many thanks! Was struggling with this problem all morning.

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Interesting blogs

Related sites

Syndication

Page view tracker