Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - Fixing the error "A file of that name is already open"

Occasionally (usually after having updated my .sln file in source control) I get a strange Visual Studio error wherein I'm unable to open some of my files. The files in question show up in the appropriate project, but trying to open them results in an error dialog saying "A file of that name is already open."

This is virtually identical to Why does it say "Project with that name already opened in the solution"?, except for files, not projects. The solution given there was does not fix this.

like image 651
JSBձոգչ Avatar asked Aug 31 '09 20:08

JSBձոգչ


2 Answers

Visual Studio internally maintains a list of currently opened files, to avoid problems caused by opening files more than once. Any number of things (crashes, reboots, updating files in source control outside of VS) can cause this list to become corrupted.

In any case, the problem can be fixed by deleting the hidden Solution.suo file which is in the same directory as your Solution.sln file. This will cause you to lose your current workspace state (open files, window layout, etc.), but it won't have any other adverse affects on your solution.

This is a hidden file, so to see or delete it you either have to enable viewing hidden files in Explorer or use del /AH Solution.suo on the command-line.

like image 183
JSBձոգչ Avatar answered Oct 26 '22 09:10

JSBձոգչ


Delete the hidden .suo file and edit the .csproj file to remove the lines below:

<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>

Now, reopen the solution to solve the issue.

like image 43
Pratham Avatar answered Oct 26 '22 10:10

Pratham