Search code examples
visual-studio-2008projects-and-solutions

About the leading newline in Visual Studio solution files


Sometimes, for unknown reasons, VS 2008 creates solution files led by a newline.


Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
[...]

This happened on various machines, and I have no idea why this is. A Google search did not yield any useful results.

Now, why do I worry about this? Because I can't open these solutions in Windows Explorer. I have to open VS, select File -> Open -> Solution and it works fine. But to open solutions from within Explorer, I have to edit the sln file and remove the leading newline.

Edit: After Leom's suggestion I tested a few times and found that the issue is solely dependent on the leading newline.

Edit: Interesting: VS 2010 displays the same behavior the other way around: It only works with a leading newline! At least on some solutions - on other solutions it's exactly the same as with VS 2008. I'm confused.


Solution

  • I too have a blank line in my solution files, but I do not have this issue.

    I did some digging, it appears that solution files actually launch the Visual Studio Version Selector, and the first 2 lines (not sure if it the actual first 2 lines, or the first 2 lines of text) of the .sln file act as the input parameters for this selector.

    There could have been a possible corruption of this executable.

    In addition, you may try in Visual Studio Tools->Options->Environment->General and choose the "Restore File Assoications".