在 VS 扩展项目中,打开文件时出现此错误 [存在具有相同名称属性的重复 EditorFormatDefinition 导出]

In VS Extension project, Opening a file, I get this error [Duplicate EditorFormatDefinition exports with identical name attributes exist]

在 Visual Studio 扩展项目中,打开一个文件,我得到了下面的弹出窗口。

导航到特定位置我得到错误信息

System.ComponentModel.Composition.ImportCardinalityMismatchException: Duplicate EditorFormatDefinition exports with identical name attributes exist. Duplicate name is keyword at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

如何解决这个问题?。提前致谢

Duplicate EditorFormatDefinition exports with identical name attributes exist.

这可能类似于 this issue. Normally the error message Duplicate EditorFormatDefinition exports with identical name attributes exist indicates you have conflicting extensions installed in your VS. More similar posts see here(one and two)。

您可以尝试以下步骤解决:

1.Go Tools=>Extensions and Updates禁用或卸载那里的所有第三方扩展,然后关闭VS使更改生效。 (卸载它们可能会更好地清洁环境)

2.Clean VS components cache 并重启 VS 以检查问题是否已通过创建新的 VSIX 项目得到解决

如果#1、#2 有助于解决此问题,我们可以确保它来自第三方扩展。将第三方扩展一一安装回去可能有助于定位是哪个扩展导致的。

3.If 问题仍然存在,可能是 VS IDE 出了问题。将 VS 更新到最新版本或 运行 修复 VS 以检查是否有任何不同。

此外:建议我们将VS2017更新到最新的15.9.17,并更新那些扩展。这将有助于避免遇到此类问题。