Word 文件从“解决方案项目”中消失在VS2010中
我在使用 VS2010 时遇到了一个问题(它也存在于最新版本 SP1 (10.0.40219.1) 中):
- 将现有的 Word 文件添加到“解决方案项目”中,然后签入这个新文件。
- 签出该文件进行编辑
- 双击该文件并在 Word 中对其进行编辑(只需进行一些细微更改)
- 保存文件 (CTRL-S)
- 现在该文件已从 Visual Studio 中的“解决方案项目”中删除(您可能需要重复编辑并保存几次)
更新:我正在使用 Visual SourceSafe 2005。
尽管我进行了研究工作,但除了此 Microsoft 页面,我想知道是否有一种方法可以防止这个问题的发生。
任何想法都非常受欢迎,提前致谢。
G。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过进一步调查,我想我找到了这种行为背后的原因和解决方法。
另请注意,原始问题中描述的行为仅发生在直接添加到解决方案下或直接添加到解决方案下的文件夹中的文件。
原因
I我不确定以下内容是否 100% 正确,但要点是 Word(可能还有其他 MS Office 应用程序)如何保存现有文件:
Visual Studio 发现该文件不存在(虽然时间很短)并将其从树和 .sln 文件中删除。这也可以通过手动添加任何类型的文件、将其签出(如果未签出)、将其重命名为其他名称,然后返回其原始名称来重现=>文件不再显示在 Visual Studio 中。
解决方法
我已按照 微软网站。我还将输出设置为“类库”,以便即使不存在静态 main 方法,项目也能编译。该模板可用于将“文档”项目添加到现有解决方案中。在此项目下,您可以添加文件并根据需要进行编辑,因为 Visual Studio 的行为有所不同,并且在文件保存在此星座中时不会删除文件。
显然这种方法仍然不是很令人满意或优雅,但我希望它对可能遇到同样问题的其他人有所帮助。
G。
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:
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.
我遇到了同样的问题。我只需在关闭文档文件后撤消对解决方案的更改,解决方案文件将保持文档更改之前的原始状态。
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.