在Visual Studio 2010中调试和修复ObjectDisposedException

jmo*_*era 16 debugging wpf xaml exception visual-studio-2010

编辑XAML文件时,我注意到以下错误:

System.ObjectDisposedException occurred
  Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
Run Code Online (Sandbox Code Playgroud)

为了调试这个,我运行了另一个Visual Studios实例和"Debug-> Attach to Process"到Visual studio的实例,其中显示了异常.

我能够在启动附加到进程的新实例中捕获异常.我遇到以下异常:

System.ObjectDisposedException occurred
  Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
  Source=Microsoft.VisualStudio.CSharp.Services.Language
  ObjectName=FileCodeModel
  StackTrace:
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CFileCodeModel.GetCompilation(Boolean fBlockForParses)
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.EnumerateParts()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.get_Count()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CSlowSnapshot..ctor(CodeElements collection)
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.CreateSnapshot()
       at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCollectionBase.GetEnumerator()
       at EnvDTE.CodeElements.GetEnumerator()
       at MS.Internal.VSSymbols.SymbolProvider.GetProperties(String fullName, Boolean isTypeDefinition, Boolean useCodeModel)
       at Microsoft.Xaml.Symbols.IXamlSymbols.GetProperties(String typeName, Boolean isTypeDefinition, Boolean useCodeModel)
       at MS.Internal.Design.Markup.HostedType.BuildProperties(Boolean useCodeModel)
  InnerException: 
Run Code Online (Sandbox Code Playgroud)

任何人都会在你的XAML中遇到这个异常,你会怎么做才能修复它.

Bac*_*Sah 2

您是否正在运行 XAML 美化器?- 我有类似的东西,有一个清理 XAML 的扩展。