Visual Studio 在记事本中打开 .xml 文件

发布于 2024-08-16 23:11:04 字数 811 浏览 4 评论 0原文

因此,今天早上我很高兴致力于一个大量使用自定义 .xml 配置文件的项目。

突然间,每当我在解决方案资源管理器中双击 .xml 文件时,它就会在记事本中打开,而不是在 Visual Studio 中打开。

我以为是Windows文件关联的问题,所以在资源管理器中右键单击一个文件,选择“打开方式”>>选择默认值,然后选择 Visual Studio 2008。

但问题仍然存在 - 现在,当我从资源管理器打开文件时,Visual Studio 打开,然后它打开记事本。

不用说,这非常令人沮丧,而且 Google 也没有多大帮助。有其他人遇到过这个问题吗?您对此做了什么?

注意:

  • 这只发生在 .xml 文件中。其他文本文件(.config、.txt)可以在 Visual Studio 中打开。
  • 这与 Windows 文件关联无关,因为 Windows 会按其应有的方式打开 VS2008。这是 Visual Studio 内部的一些疯狂问题。
  • 我也尝试过“工具>>”选项>>一般>>恢复文件关联。运气不好。
  • 工具>>中没有任何内容选项>>文本编辑器>>文件扩展名
  • 这是 .xml 文件的“打开方式”菜单的样子。如您所见,“XML 编辑器”设置为默认值。 替代文本

So I'm happily working on a project making heavy use of custom .xml configuration files this morning.

All of a sudden, whenever I double-click an .xml file in Solution Explorer, it opens in Notepad instead of within Visual Studio.

Thinking that it was the Windows file associations, I right-clicked on a file in Explorer, selected Open With >> Choose Defaults, and selected Visual Studio 2008.

But the problem remains -- now when I open a file from Explorer, Visual Studio Opens, then it opens Notepad.

Needless to say, this is very frustrating, and Google is not much help. Has anyone else ever had this problem, and what did you do about it?

Notes:

  • This only happens for .xml files. Other text files (.config, .txt) open within Visual Studio just fine.
  • This has nothing to do with Windows file associations, as Windows open up VS2008 just as it should. This is some crazy problem internal to Visual Studio.
  • I've also tried Tools >> Options >> General >> Restore File Associations. No luck.
  • Nothing present in Tools >> Options >> Text Editor >> File Extension
  • This is what my "Open With" menu looks like for .xml files. As you can see, "XML Editor" is set to the default.
    alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

蝶舞 2024-08-23 23:11:04

是的。 Visual Studio 文本编辑器似乎无法支持 UTF-16 Unicode,因此在外部编辑器中打开它。使用“UTF-8”编码重新保存 xml 文件(记住将 xml 声明也从“UTF-16”更改为“UTF-8”,然后就可以了。

Yes. Visual Studio Text Editor appears not to be able to support UTF-16 Unicode and so opens it up in an external editor. Resave the xml file with "UTF-8" encoding (remember to change your xml declaration from "UTF-16" to "UTF-8" too and then it should be fine.

在风中等你 2024-08-23 23:11:04

如果您进入“工具”>选项>文本编辑器>文件扩展名,这里有映射到记事本的内容吗?如果是这样,请将其删除,它应该会清除。另外,如果项目中有 XML 文件,您可以右键单击它,选择“打开方式”,然后选择默认编辑器。

更新:查看评论以尝试其他事情

If you go into Tools > Options > Text Editor > File Extension, do you have anything in here that is mapped to notepad? If so remove that and it should clear it up. Also, if you have an XML file in a project, you can right click on it, choose Open With and choose your default editor there.

Update: see comments for other things to try

天气好吗我好吗 2024-08-23 23:11:04

有同样的问题。尝试使用带编码的 XML 编辑器打开该文件。这样我就可以明确选择 Unicode,从而成功在 VS 中打开文件。从那里保存文件后,问题就消失了。

Had the same problem. Try opening the file with XML Editor with Encoding. That way I could explicitly choose Unicode, which successfully opened the file in VS. After saving the file from there the problems went away.

本宫微胖 2024-08-23 23:11:04

我对 .txt 文件也有类似的问题。
我尝试使用“打开方式...”从 VS 打开该文件,VS 打开它,但每个第二个字符都显示垃圾。
当我将文件保存到不同的代码页时,问题就消失了。
虽然它仍然有点奇怪,因为原始代码页中的原始文件的副本确实在 VS 中通过双击正确打开,并且也正确显示。

I had similar problem with .txt files.
I tried to open that file from VS using "Open with..." and VS opened it, but showed garbage for every second character.
The problem went away when I saved the file to a different codepage.
Though it is still a bit strange, since a copy of that original file in original codepage did open in VS with double-click correctly and and showed also correctly.

活泼老夫 2024-08-23 23:11:04

我认为“每第二个字符显示垃圾”是因为该文件被保存为 unicode,但在编辑器中被视为非 unicode

I think "showing garbage for every second character" is due to that file being saved as unicode, but treated as non unicode in the editor

流年里的时光 2024-08-23 23:11:04

安装升级后,使用 VS Express 2012 for Windows Desktop 处理 *.js 文件时,我遇到了类似的情况。运行:

rmdir /s /q  %LOCALAPPDATA%\Microsoft\WDExpress\11.0\ComponentModelCache

并重新启动 VS 解决了问题。

I had a similar situation with *.js files using VS Express 2012 for Windows Desktop after an upgrade had been installed. Running:

rmdir /s /q  %LOCALAPPDATA%\Microsoft\WDExpress\11.0\ComponentModelCache

and restarting VS resolved the issue.

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