【问题标题】:Visual studio has encountered an exceptionVisual Studio 遇到异常
【发布时间】:2018-11-08 01:45:35
【问题描述】:

所以,我正在使用 Visual Studio 2010,在过去一周或我收到来自 Visual Studio 的消息:“Visual Studio 遇到异常。这可能是由扩展引起的。”

我的 ActivityLog.xml 将日志显示为问题:

<entry>
    <record>321</record>
    <time>2012/09/20 16:52:36.126</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. 
Review the CompositionException.Errors property for more detailed information.&#x000D;&#x000A;&#x000D;&#x000A;1) Object reference not set to an instance of an object.&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: An exception occurred while calling the &apos;OnImportsSatisfied&apos; method on type &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword&apos;.&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot activate part &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword&apos;.&#x000D;&#x000A;Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword --&gt;  Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot get export &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword (ContractName=&quot;Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition&quot;)&apos; from part &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword&apos;.&#x000D;&#x000A;Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword (ContractName=&quot;Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition&quot;) --&gt;  Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword&#x000D;&#x000A;&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()&#x000D;&#x000A;   at System.ComponentModel.Composition.Primitives.Export.get_Value()&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export)&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.&lt;&gt;c__DisplayClass4`2.&lt;CreateStronglyTypedExportOfTM&gt;b__1()&#x000D;&#x000A;   at System.Lazy`1.CreateValue()&#x000D;&#x000A;   at System.Lazy`1.LazyInitValue()&#x000D;&#x000A;   at System.Lazy`1.get_Value()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension](Object errorSource, Lazy`1 provider)</description>
</entry>

<entry>
    <record>322</record>
    <time>2012/09/20 16:52:36.202</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.&#x000D;&#x000A;&#x000D;&#x000A;1) Object reference not set to an instance of an object.&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: An exception occurred while calling the &apos;OnImportsSatisfied&apos; method on type &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment&apos;.&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot activate part &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment&apos;.&#x000D;&#x000A;Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment --&gt;  Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot get export &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment (ContractName=&quot;Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition&quot;)&apos; from part &apos;Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment&apos;.&#x000D;&#x000A;Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment (ContractName=&quot;Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition&quot;) --&gt;  Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment&#x000D;&#x000A;&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()&#x000D;&#x000A;   at System.ComponentModel.Composition.Primitives.Export.get_Value()&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export)&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.&lt;&gt;c__DisplayClass4`2.&lt;CreateStronglyTypedExportOfTM&gt;b__1()&#x000D;&#x000A;   at System.Lazy`1.CreateValue()&#x000D;&#x000A;   at System.Lazy`1.LazyInitValue()&#x000D;&#x000A;   at System.Lazy`1.get_Value()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension](Object errorSource, Lazy`1 provider)</description>
</entry>

似乎没有任何特定的操作会导致这种情况,有时会在我第一次启动 VS 时发生,有时会在我离开办公桌一段时间后再回来时发生。此外,从日志来看,它似乎是在加载 Visual Studio CSS 编辑包之后立即发生的。我安装了 MVC4,可能是新 CSS 的问题(我认为是 CSS3?)

无论如何,只是想知道是否有人以前遇到过这种情况并有某种解决方案。

【问题讨论】:

标签: visual-studio-2010 visual-studio


【解决方案1】:

似乎某些 VS 扩展可能导致它崩溃。 (你最近安装过扩展吗?)

尝试在安全模式下运行 VS 以诊断问题。

运行此命令并检查 VS 是否启动

devenv.exe /safemode

这里有更多

http://blog.meidianto.com/2010/05/16/vs2010-tips-8-got-annoying-visual-studio-2010-error-try-to-run-in-safe-mode/

【讨论】:

  • 是的,不幸的是它仍然在安全模式下发生,同样的错误
  • 可能会尝试修复/重新安装 VS 安装.. 这可能会有所帮助.. 也可能您可以使用此处的工具为 VS 提交错误.. blogs.msdn.com/b/visualstudio/archive/2012/06/20/…
  • 是的,我想我最终会这样做,它现在没有崩溃或任何事情,只是更烦人。
  • 我确实重新安装了,但看到它继续发生几次。不过,它现在似乎已经消失了。
  • 这些 MEF 错误通常是由于缓存文件夹损坏而发生的,清除所述缓存文件夹通常可以解决问题:stackoverflow.com/a/20301710/736079
【解决方案2】:

VS 需要管理员权限来处理插件。所以右键单击VS并单击“以管理员身份运行”。它为我解决了。尝试一次。

【讨论】:

    【解决方案3】:

    我遇到了同样的错误,我的ActivityLog.xml 显示以下错误:

    System.ComponentModel.Composition.CompositionException: 合成产生了一个单一的合成错误。根本原因是 下面提供。查看 CompositionException.Errors 属性 更详细的信息。 1) 没有 找到与约束匹配的导出: 合同名称 Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator RequiredTypeIdentity Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator 结果 在:无法设置导入 'Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+SingleImporter.Import (ContractName="Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator")' 部分 'Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+SingleImporter'。 元素: Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+SingleImporter.Import (ContractName="Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator") --> Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+SingleImporter 在 System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition 原子组成) 在 System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart 部分) 在 System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart 部分) 在 Microsoft.VisualStudio.Composition.NetFxAdapters.CompositionService.SatisfyImportsOnce(ComposablePart 部分) 在 System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService 组合服务,对象属性部分) 在 Microsoft.Web.Editor.Composition.ComponentLocator`1.Import() 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.LinterUtilities.c.<.cctor>b__4_1() 在 System.Lazy`1.CreateValue() 在 System.Lazy`1.LazyInitValue() 在 System.Lazy`1.get_Value() 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.LinterUtilities.IsFileSupported(字符串 文件名) 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.ErrorTagger.LintErrorTaggerProvider.CreateTagger[T](ITextBuffer 文本缓冲区) 在 Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer 文本缓冲区)

    通过转到工具 -> 扩展和更新 -> 更新 -> Visual Studio 库 -> 安装了Microsoft ASP.NET and Web Tools的新版本来解决它

    【讨论】:

      【解决方案4】:

      (以下解决方案对我有用)

      我只是单击了解决方案文件,默认情况下它试图在 Visual Studio 2015 中打开 *.sln 文件,然后我收到错误消息“Visual Studio 遇到异常。这可能是由扩展引起的”。

      我安装了两个 Visual Studio 版本 - Visual Studio 2015 和 Visual Studio 2017。我在记事本中打开 *.sln 文件,我可以看到 VisualStudioVersion = 14.0.24720.0,这表明该解决方案是在 Visual Studio 2015 中创建的。

      然后我右击 *.sln 文件并选择 vs 2017 打开它。然后就成功打开了。我最好的猜测是 Visual Studio 2015 扩展之一没有正确加载,这就是我收到该错误消息的原因。

      【讨论】:

        【解决方案5】:

        试试这个 工具->导入和导出设置->重置所有设置。

        【讨论】:

          【解决方案6】:

          为您的 VS 版本下载网络要点。它对我关于 ActivityLog.xml 的问题进行了排序。 Web Essential

          【讨论】:

            猜你喜欢
            • 2019-06-07
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多