Word 文件从“解决方案项目”中消失在VS2010中

发布于 2024-10-27 18:48:04 字数 566 浏览 0 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等待圉鍢 2024-11-03 18:48:04

经过进一步调查,我想我找到了这种行为背后的原因和解决方法。

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

原因

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

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

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:

  • 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.

大海や 2024-11-03 18:48:04

我遇到了同样的问题。我只需在关闭文档文件后撤消对解决方案的更改,解决方案文件将保持文档更改之前的原始状态。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文