Word文件从“解决方案项目"(Solution Items)中消失.在VS2010中 [英] Word files disappear from "Solution Items" in VS2010

查看:184
本文介绍了Word文件从“解决方案项目"(Solution Items)中消失.在VS2010中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了VS2010的问题(它也存在于最新版本SP1(10.0.40219.1)中):

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

  • 将现有的Word文件添加到解决方案项目"中,然后签入该新文件.
  • 检出文件进行编辑
  • 双击文件并在Word中对其进行编辑(只需做一些小的更改)
  • 保存文件(CTRL-S)
  • 现在,该文件已从Visual Studio中的解决方案项"中删除(您可能必须重复编辑并保存几次)

更新:我正在使用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.

推荐答案

经过进一步调查,我认为我发现了此行为的原因以及解决方法.

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

请注意,原始问题中描述的行为仅发生在直接添加到解决方案下或添加到解决方案下的文件夹中的文件中.

原因

我不确定以下内容是否100%正确,但是重点是Word(以及其他MS Office应用程序)如何保存现有文件:

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:

  • 将文件的当前版本保存到临时文件
  • 重命名原始文件,以便以后出现问题时可以使用
  • 使用原始文件的名称将临时文件复制到原始文件的位置
  • 删除原始文件(在步骤2中重命名)

Visual Studio会发现该文件不存在(虽然时间很短),然后将其从树和.sln文件中删除.也可以通过手动添加任何类型的文件,将其检出(如果未检出),将其重命名为其他名称,然后重命名为原始名称=>文件,来重现该文件.

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.

解决方法

我已经按照 Microsoft的网站上的步骤创建了一个空项目模板..我还将输出设置为"Class Library",以便即使不存在静态main方法也可以编译项目.此模板可用于将文档"项目添加到现有解决方案.在该项目下,您可以根据需要添加文件并对其进行编辑,因为Visual Studio的行为有所不同,并且在将文件保存在该星座中时不会删除文件.

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.

这篇关于Word文件从“解决方案项目"(Solution Items)中消失.在VS2010中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆