启动 Visual Studio 2012 出现错误

27
每次我启动Visual Studio时都会出现错误消息。由于我还看到一些无法解释的行为在我的项目中,所以我想解决这个问题。 错误消息

已遇到异常情况。这可能是由扩展引起的。

您可以通过检查文件“C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml”来获取更多信息。

当我查看日志文件时,我发现两个异常: 错误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)

我该如何解释这个问题以便找出错误?

8个回答

21

看起来VSCommands扩展或其他插件出了问题。您可以尝试禁用所有扩展,重启Visual Studio并重新启用它们;有时可以解决这种问题。

另一件您可以尝试的事情是以管理员身份运行Visual Studio,因为如果没有足够的权限访问某些资源,可能会出现此错误(这是旧版本Visual Studio中的错误)。

您最后的痛苦选择将是进行干净的重新安装。


你知道有没有一种简单的方法来禁用所有扩展吗? - Jonathan Wood
2
我所知道的唯一方法是在扩展管理器中逐个禁用它们(工具 -> 扩展和更新)。此外,重新安装扩展可能是一个解决方案,比安装VS更少痛苦。 - iTech
1
啊,好建议。我禁用了第一个(你建议的Visual Studio 2012的VSCommands),错误就停止了。真是该提供更好的错误报告! - Jonathan Wood
2
嗨,之前VSCommands和一些其他扩展(如EF Power Tools Beta 2)之间存在兼容性问题,但在最新版本中已经修复了这些问题。 - Jarek Kardas
哇,我刚刚在安装更新4后遇到了这个问题,并通过禁用Visual Assist X解决了它。注意:仅通过VASSISTX菜单禁用VAX是不够的。请使用上面提到的对话框(工具->扩展和更新)来禁用它。 - TobiMcNamobi
我同意iTech的答案,但正如这里所说,你可以在进行干净安装之前进行修复。这对我很有效。 - MGamsby

13

9

通过删除以下文件夹来解决问题:

C:\Users{用户名}\AppData\Local\Microsoft\VisualStudio{版本号}\ComponentModelCache

注意:请勿忽略大括号 {} 中的变量。

4
安装 Visual Studio 2012 Update 2 后,出现了这个错误。显然,Web 工具和 Web Essentials 2012 扩展存在冲突 - 它们都试图注册一些相同的组件,从而生成此异常。
此外,当安装 VS 2012 Update 2 时,似乎一个或两个扩展的自动更新通知已经失效,因为虽然已经更新了这些扩展以解决冲突,但您并未收到有关更新的通知。
解决方案是删除这两个扩展,然后重新安装它们。
有关更多信息,请参见 http://madskristensen.net/post/web-tools-20122-and-web-essentials

2
+1 在更改 BuildSolution 的键盘快捷键后,我也遇到了同样的问题。禁用了 Web Essentials 2012 - 问题依旧。卸载了 Web Essentials - 问题解决了。重新安装 Web Essentials - 一切都好! :) - Aximili

3

我遇到了同样的错误,注意到NuGet Package Manager扩展程序有一个更新版本。安装了这个更新版本后,错误就消失了。

确保所有可用的更新都已应用。要检查是否有任何更新可用,请打开“工具”>“扩展和更新”菜单。在“扩展和更新”对话框中,在左侧窗格中展开“更新”节点。安装可能可用的任何更新,并重新启动Visual Studio 2012。


这对我有效。我更新的扩展名正是Nuget包管理器。 - HOKBONG

2
对于所有遇到这个问题的人:
  1. 打开Visual Studio 2012,但不要加载任何解决方案/项目
  2. 从“工具”菜单中打开“扩展和更新”
  3. 禁用Web Essentials 2012
  4. 删除您的解决方案的.suo文件
  5. 在Visual Studio中打开解决方案
  6. 查看它是否已经加载,Visual Studio没有崩溃
  7. 启用Web Essentials 2012
  8. 重新启动Visual Studio 2012并重新加载您的解决方案。
  9. 愉快的时光!
来源: 原文链接

2

解决上述问题所需的全部操作就是删除项目和Visual Studio的*.suo文件。我曾经遇到过同样的问题。


谢谢!对我有用。 - Halil Ibrahim

0

我也遇到了同样的错误:

已经发生了异常。这可能是由扩展引起的。

您可以通过检查文件'C:\ Users \ ... \ VisualStudio \ 11.0 \ ActivityLog.xml'来获取更多信息

原因:

我从控制面板中卸载了一些SQL文件。只有在那之后,我才开始出现这个错误,但我不确定我卸载了哪个服务。

解决方案:

我下载了Visual Studio 2012 SDK并安装/重新启动Visual Studio,然后它就正常工作了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接