Error starting Visual Studio 2012

2019-01-18 02:16发布

问题:

I'm getting an error message every time I start Visual Studio. Since I'm also seeing some unexplained behavior in my project, I'd like to resolve this issue.

Error Message

An exception has been encountered. This may be caused by an extension.

You can get more information by examining the file 'C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml'.

When I look at the log file, I find two exceptions:

Error 1

Exception Type       : System.Windows.Markup.XamlParseException
Exception Message    : Provide value on 'System.Windows.StaticResourceExtension' threw an exception.
Exception Stack Trace:
    at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
    at SquaredInfinity.VSCommands.UI.Views.DefaultAlertView.InitializeComponent()
    at SquaredInfinity.VSCommands.Foundation.Services.VSCUIService.GetDefaultAlertViewModel(String alertMessage, String alertDialogTitle)
    at SquaredInfinity.Foundation.Presentation.Services.UIService.GetDefaultAlertViewModel(String alertMessage)
    at SquaredInfinity.Foundation.Presentation.Services.UIService.ShowAlert(String message)
    at SquaredInfinity.VSCommands.VSCommandsPackage.Initialize()
Exception Data   : [EmptyOrNull]
Inner Exception:
Exception Type       : System.Exception
Exception Message    : Cannot find resource named 'VSC.Button'. Resource names are case sensitive.
Exception Stack Trace:    at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
                      at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
                      at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
Exception Data   : [EmptyOrNull]

Error 2

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) The current type,    SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
Resulting in: Resolution of the dependency failed, type = "SquaredInfinity.Foundation.Configuration.Services.IConfigurationService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
  Resolving SquaredInfinity.Foundation.Configuration.Services.IConfigurationService,(none)

Resulting in: An exception occurred while trying to create an instance of type '#Btb.#Rtb'.

Resulting in: Cannot activate part '#Btb.#Rtb'.
Element: #Btb.#Rtb -->  #Btb.#Rtb

Resulting in: Cannot get export '#Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider")' from part '#Btb.#Rtb'.
Element: #Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider") -->  #Btb.#Rtb

   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart 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.GetCastedExportedValue[T](Export export)
   at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InvokeMatchingFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable`1 lazyFactories, Func`2 getter, IContentType dataContentType, Object errorSource)

How do I interpret this so that I can figure out the error?

回答1:

It seems there is something wrong with the VSCommands extension or another plugin. You can try to disable all extensions, restart Visual Studio and re-enable them; sometimes it resolves such issue.

Another thing you can try, is to run Visual Studio as administrator, because this error can occur if there are not sufficient permissions to access some resources (it was a bug in older releases of Visual Studio).

Your last painful resort will be a clean re-installation.



回答2:

Just reinstall latest Web Essentials 5/5/2013. It resolves the problem. No need to uninstall or disable anything, just run setup again and you are done.

http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6



回答3:

Fixed by deleting the following folder:

C:\Users{username}\AppData\Local\Microsoft\VisualStudio{version-number}\ComponentModelCache



回答4:

This error starts after installing Visual Studio 2012 Update 2. Apparently the Web Tools and Web Essentials 2012 extensions have a conflict -- they both try to register some of the same components, which generates this exception.

Additionally, it appears the automatic update notification for one or both of these extensions is broken when VS 2012 Update 2 is installed, because though the extensions have been updated to resolve the conflict, you aren't notified that an update exists.

The solution is to remove both extensions, then reinstall them.

For more information about this, see http://madskristensen.net/post/web-tools-20122-and-web-essentials.



回答5:

I was getting this same error. I noticed that the NuGet Package Manager extension had an update. After installing this update, the error went away.

Make sure all available updates are applied. To check if there are any updates available open Tools > Extensions and Updates. In the "Extensions and Updates" dialog, expand the "Updates" node in the left pane. Install any updates that may be available and restart Visual Studio 2012.



回答6:

For all people having this problem:

  1. Open Visual Studio 2012, but don't load any solutions / projects
  2. Open Extensions and Updates from the Tools menu
  3. Disable Web Essentials 2012
  4. Delete the .suo file for your solution
  5. Open the solution in Visual Studio
  6. See that it loads and Visual Studio doesn't crash
  7. Enable Web Essentials 2012
  8. Restart Visual Studio 2012 and reload your solution.
  9. Happy times!

Source



回答7:

All you need to resolve the above stated issue is to delete the *.suo file for the project and Visual Studio. I had the same issue.



回答8:

I was also getting the same error:

An exception has been encountered. This may be caused by an extension.

You can get more information by examining the file 'C:\Users\ . . . \VisualStudio\11.0\ActivityLog.xml'

Reason:

I had uninstalled some of the SQL files from the control panel. Only after that did I start to get this error, but I was not sure which service I had uninstalled.

Solution:

I downloaded the SDK for Visual Studio 2012 and installed/restarted Visual Studio, then it worked fine.