Question

I've run into a problem with VS2010 (it also exists in the latest version, SP1 (10.0.40219.1)):

  • Add an existing Word file to the "Solution Items" and check this new file in.
  • Check the file out for editing
  • Double click on the file and edit it in Word (just make some minor changes)
  • Save the file (CTRL-S)
  • Now the file is removed from the "Solution Items" in Visual Studio (you may have to repeat the editing and saving a couple of times)

Update: I'm using Visual SourceSafe 2005.

Despite my research efforts I haven't really found anything on this issue apart from this Microsoft page, and I'd like to know whether there is a way to prevent this problem from happening.

Any ideas are more than welcome, thanks in advance.

G.

Was it helpful?

Solution

After further investigation I think I found the reason behind this behaviour and a workaround.

Please also note that the behaviour described in the original question only occurs for files that are added directly underneath a solution or to a folder that is directly underneath a solution.

The reason

I'm not sure whether the following is 100% correct, but the main point is how Word (and probably other MS Office apps as well) saves an existing file:

  • Save the current version of the file to a temporary file
  • Rename the original file so it can be used later in case something goes wrong
  • Copy the temporary file to the location of the original file, using the original file's name
  • Delete the original file (that was renamed in step 2)

Visual Studio picks up that the file doesn't exist (for a very short time though) and removes it from its tree and the .sln file. This can also be reproduced by manually adding any kind of file, checking it out (if not checked out), renaming it to a different name and then back to its original name => file is no longer shown in Visual Studio.

The workaround

I've created an empty project template following the steps on Microsoft's site. I also set the output to "Class Library" so that the project would compile even if no static main method exists. This template can be used to add a "Documentation" project to an existing solution. Underneath this project you can add files and edit them as you wish, as Visual Studio behaves differently and does not remove the file when it is saved in this constellation.

Obviously this approach is still not very satisfying or elegant, but I hope that it may be helpful for others who might run into the same problem.

G.

OTHER TIPS

I've run into the same issue. I simply undo changes for the solution after I've closed the document file and the solution files will be as they originally were before your document changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top