所以,我正在使用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.

1) Object reference not set to an instance of an object.

Resulting in: An exception occurred while calling the 'OnImportsSatisfied' method on type 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword'.

Resulting in: Cannot activate part 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword'.
Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword --> Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword

Resulting in: Cannot get export 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword (ContractName="Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition")' from part 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword'.
Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword (ContractName="Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition") --> Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSKeyword

 at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
 at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart)
 at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
 at System.ComponentModel.Composition.Primitives.Export.get_Value()
 at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export)
 at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedExportOfTM>b__1()
 at System.Lazy`1.CreateValue()
 at System.Lazy`1.LazyInitValue()
 at System.Lazy`1.get_Value()
 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.

1) Object reference not set to an instance of an object.

Resulting in: An exception occurred while calling the 'OnImportsSatisfied' method on type 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment'.

Resulting in: Cannot activate part 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment'.
Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment --> Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment

Resulting in: Cannot get export 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment (ContractName="Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition")' from part 'Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment'.
Element: Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment (ContractName="Microsoft.VisualStudio.Text.Classification.EditorFormatDefinition") --> Microsoft.VisualStudio.Web.Exports.ExportedClassificationFormatCSSComment

 at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
 at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart)
 at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
 at System.ComponentModel.Composition.Primitives.Export.get_Value()
 at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export)
 at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedExportOfTM>b__1()
 at System.Lazy`1.CreateValue()
 at System.Lazy`1.LazyInitValue()
 at System.Lazy`1.get_Value()
 at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension](Object errorSource, Lazy`1 provider)</description>
</entry>
似乎没有任何特定的动作导致这种情况,有时它发生在我第一次启动VS时,有时候我离开办公桌一段时间后又回来了。此外,从日志中,它似乎在加载Visual Studio CSS编辑包后立即发生。我安装了MVC4,也许这是新CSS的问题(CSS3我认为?)
无论如何,只是想知道是否有人之前碰到过这种情况并且有某种解决方法。
答案 0 :(得分:5)
似乎有些VS扩展可能导致它崩溃。 (你最近是否安装了扩展程序?)
尝试在安全模式下运行VS来诊断问题。
运行此命令并检查VS是否启动
devenv.exe /safemode
更多信息
答案 1 :(得分:4)
VS需要管理员权限才能处理插件。所以右键单击VS并单击“RUN AS ADMINISTRATOR”。它为我解决了。试一次。
答案 2 :(得分:0)
我遇到了同样的错误,我的ActivityLog.xml
显示以下错误:
System.ComponentModel.Composition.CompositionException:The 组成产生单一成分错误。根本原因是 提供如下。查看CompositionException.Errors属性 更详细的信息。&#13; &#13; 1)没有 找到符合约束条件的导出: ContractName Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator RequiredTypeIdentity Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator&#13; &#13; 造成 in:无法设置导入 &#39; Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+ SingleImporter.Import (ContractName =&#34; Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator&#34)&#39; 在一部分 &#39; Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+ SingleImporter&#39;&#13; 元件: Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+ SingleImporter.Import (ContractName =&#34; Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator&#34) - &GT; Microsoft.Web.Editor.Composition.ComponentLocator(Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.IWebLinterAggregator)+ SingleImporter&#13; &#13; 在 System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)&#13; 在 System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart 一部分)&#13; 在 System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart 一部分)&#13; 在 Microsoft.VisualStudio.Composition.NetFxAdapters.CompositionService.SatisfyImportsOnce(ComposablePart 一部分)&#13; 在 System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService,Object attributionPart)&#13; 在 Microsoft.Web.Editor.Composition.ComponentLocator`1.Import()&#13; 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.LinterUtilities&LT;&GT;℃下.cctor&GT; b__4_1()&#13; 在System.Lazy`1.CreateValue()&#13; 在 System.Lazy`1.LazyInitValue()&#13; 在 System.Lazy`1.get_Value()&#13; 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.WebLinter.LinterUtilities.IsFileSupported(字符串 文件名)&#13; 在 Microsoft.VisualStudio.Web.Editor.Package.Lint.ErrorTagger.LintErrorTaggerProvider.CreateTagger [T](ITextBuffer textBuffer)&#13; 在 Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)
转到工具 - &gt;解决了这个问题。扩展程序和更新 - &gt;更新 - &gt; Visual Studio Gallery - &gt;已安装新版Microsoft ASP.NET and Web Tools
答案 3 :(得分:0)
(以下解决方案对我有用)
我只是单击解决方案文件,默认情况下它尝试在Visual Studio 2015中打开* .sln文件,然后出现错误消息“ Visual Studio遇到异常。这可能是由于扩展名引起的”。
我安装了两个Visual Studio版本-Visual Studio 2015和Visual Studio2017。我在记事本中打开了* .sln文件,我看到VisualStudioVersion = 14.0.24720.0表示该解决方案是在Visual Studio 2015中创建的。>
然后,我右键单击* .sln文件,然后选择vs 2017打开它。然后它已成功打开。我最好的猜测是Visual Studio 2015扩展程序无法正确加载,这就是为什么我收到该错误消息的原因。
答案 4 :(得分:-1)
试试这个 工具 - &gt;导入和导出设置 - &gt;重置所有设置。
答案 5 :(得分:-1)
下载适用于您的VS版本的网络基础知识。它对我关于ActivityLog.xml的问题进行了排序。 Web Essential