首页 > 解决方案 > 如何控制堆栈跟踪的深度

问题描述

拥有使用 DevExpress 的 C# WPF 应用程序。捕获一个未处理的异常,见下文,它显示了 System 和 DevExpress 元素,但没有来自我的任何源模块。几乎可以肯定,我的一个源模块正在写入一个绑定到 DevExpress PropertyGridControl 的 C# 对象,然后抛出异常,但是哪个 PropertyGridControl?有没有办法扩展或扩大堆栈跟踪深度,以查看在我的源代码中对 C# 对象的写入发生在哪里?

OnDispatcherUnhandledException occurred: Collection was modified after the enumerator was instantiated. 
at System.Collections.Specialized.ListDictionary.NodeKeyValueCollection.NodeKeyValueEnumerator.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__94`1.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at DevExpress.Mvvm.Native.LinqExtensions.ForEach[T](IEnumerable`1 source, Action`1 action)
at DevExpress.Xpf.PropertyGrid.Internal.DataController.InvalidateChildren(IEnumerable`1 handles)
at DevExpress.Xpf.PropertyGrid.Internal.DataController.UpdateHandles()
at DevExpress.Xpf.PropertyGrid.Internal.DataController.Update()
at DevExpress.Xpf.PropertyGrid.Internal.DataViewBase.<Update>b__98_0()
at DevExpress.Xpf.Core.Locker.DoLockedAction(Action action)
at DevExpress.Xpf.Core.Locker.<>c__DisplayClass12_0.<DoLockedActionIfNotLocked>b__0()
at DevExpress.Xpf.Core.Locker.DoIfNotLocked(Action action)
at DevExpress.Xpf.Core.Locker.DoLockedActionIfNotLocked(Action action)
at DevExpress.Xpf.PropertyGrid.Internal.DataViewBase.Update()
at DevExpress.Xpf.PropertyGrid.PropertyGridControl.UpdateData()
at DevExpress.Xpf.PropertyGrid.PropertyGridView.<OnLayoutUpdated>b__103_0(PropertyGridControl x)
at DevExpress.Mvvm.Native.MayBe.Do[TI](TI input, Action`1 action)
at DevExpress.Xpf.PropertyGrid.PropertyGridView.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) 

标签: c#wpfstack-trace

解决方案


值得称赞的是,DevExpress 拥有一个导致我观察到的异常的实现。他们的代码异步处理 DataContext 绑定,因此很明显,当一个绑定更新被异步处理时,另一个同时发生的绑定更新可能会导致 kaboom。新版本即将发布...


推荐阅读