编辑XAML文件时,我注意到以下错误:
System.ObjectDisposedException occurred
Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
为了进行调试,我运行了Visual Studios的另一个实例,并在显示异常的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:
任何人都曾在您的XAML中遇到此异常,以及您如何解决该异常。
最佳答案
您正在运行XAML美化器吗? -我有类似的扩展程序可以清理XAML。
关于wpf - 在Visual Studio 2010中调试和修复ObjectDisposedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9315356/