所以,我使用的是 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?)
无论如何,只是想知道是否有人以前遇到过这种情况并有某种解决方案。