Visual-studio – Visual studio has encountered an exception

visual studiovisual studio 2010

So, I'm using Visual Studio 2010, and in the past week or I'm getting a message from Visual Studio coming up: "Visual Studio has encountered an exception. This may be caused by an extension."

My ActivityLog.xml reveals logs this as the problem:

<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>

There doesn't seem to be any specific action that causes this, sometimes it happens when I first fire up VS, sometimes after I leave my desk for awhile and come back. Also, from the log, it appears to happen right after loading the Visual Studio CSS Editing Package. I have MVC4 installed, maybe it's a problem with the new CSS (CSS3 I think?)

Anyways, just wondering if anybody had run into this before and had some sort of resolution.

Best Answer

seems some VS extension may be causing it to crash. (did you install extension any recently?)

try running VS in safe mode to diagnose the problem.

Run this command and check if VS starts

devenv.exe /safemode

More here

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