根本原因:对自动化对等 API 的递归调用无效
Posted
技术标签:
【中文标题】根本原因:对自动化对等 API 的递归调用无效【英文标题】:Root Cause: Recursive call to Automation Peer API is not valid 【发布时间】:2013-03-30 06:50:04 【问题描述】:我们已经使用 WPF Tookit DataGrid 和 .NET 3.5 大约 2 年了。我们有两种抛出异常的情况——“对自动化对等 API 的递归调用无效”。 已经很奇怪了,很少有电脑有这样的问题。
案例一:
一个下拉组合框(WPF Tookit DataGrid 作为 DropDown 内容控件):
可以通过以下方式解决:
protected override AutomationPeer OnCreateAutomationPeer()
return null;
此解决方案来自WPF Recursive call to Automation Peer API is not valid。
案例二:
一个 WPF Tookit DataGrid 有一个 Temlate Column ,其中单元格模板有一个下拉组合框(WPF Tookit DataGrid 作为 DropDown 内容控件)。上面的解决方案无法解决。
*Exception Stack:
Exception object: 0ac4e048
Exception type: System.InvalidOperationException
Message: Recursive call to Automation Peer API is not valid.
InnerException: <none>
StackTrace (generated):
SP IP Function
0036E3A4 61A0CEFE PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.GetChildren()+0x366bde
0036E3D4 616A5C34 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x18
0036E3EC 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E404 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E41C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E434 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E44C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E464 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E47C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E494 616A5E52 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(System.Windows.Automation.Peers.AutomationPeer)+0xaa
0036E4A8 616A444E PresentationCore_ni!MS.Internal.Automation.ElementProxy.StaticWrap(System.Windows.Automation.Peers.AutomationPeer, System.Windows.Automation.Peers.AutomationPeer)+0x1a
0036E4C0 616A7C69 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32)+0x341
0036E52C 616A791A PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()+0xa
0036E530 11EDC66E UNKNOWN!Microsoft.Windows.Automation.Peers.DataGridItemAutomationPeer.GetChildrenCore()+0x1e
0036E540 616A662B PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()+0x23
0036E558 616A634C PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.GetChildren()+0x2c
0036E588 616A5C34 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x18
0036E5A0 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E5B8 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E5D0 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E5E8 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E600 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E618 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E630 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E648 616A5E52 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(System.Windows.Automation.Peers.AutomationPeer)+0xaa
0036E65C 616A444E PresentationCore_ni!MS.Internal.Automation.ElementProxy.StaticWrap(System.Windows.Automation.Peers.AutomationPeer, System.Windows.Automation.Peers.AutomationPeer)+0x1a
0036E674 616A6F3E PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ProviderFromPeer(System.Windows.Automation.Peers.AutomationPeer)+0x1e
0036E680 619DBBD1 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.RaiseAutomationEvent(System.Windows.Automation.Peers.AutomationEvents)+0x7ab6d5
0036E690 609783AA PresentationFramework_ni!System.Windows.Automation.Peers.SelectorAutomationPeer.RaiseSelectionEvents(System.Windows.Controls.SelectionChangedEventArgs)+0x22
0036E6B0 60C48560 PresentationFramework_ni!System.Windows.Controls.ComboBox.OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs)+0xbef278
0036E6C4 124C17E7 UNKNOWN!UNKNOWN+0x17
0036E6EC 60061113 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(System.Collections.Generic.List`1<System.Object>, System.Collections.Generic.List`1<System.Object>)+0x4f
0036E704 6005FE17 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector+SelectionChanger.End()+0xdf
0036E738 6005E325 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector+SelectionChanger.SelectJustThisItem(System.Object, Boolean)+0x11d
0036E76C 60060D02 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector.OnSelectedItemChanged(System.Windows.DependencyObject, System.Windows.DependencyPropertyChangedEventArgs)+0xb2
0036E798 627585EC WindowsBase_ni!Unknown+0x4c
0036E7C4 60073E40 PresentationFramework_ni!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)+0x50
0036E8F4 627583BC WindowsBase_ni!Unknown+0x3c
0036E94C 6275676B WindowsBase_ni!Unknown+0x71b
0036EA0C 627594CD WindowsBase_ni!Unknown+0xad
0036EA34 600AD85A PresentationFramework_ni!System.Windows.Data.BindingExpressionBase.Invalidate(Boolean)+0x62
0036EA4C 600AD31D PresentationFramework_ni!System.Windows.Data.BindingExpression.TransferValue(System.Object, Boolean)+0x1fd
0036EAA0 600AA9D8 PresentationFramework_ni!System.Windows.Data.BindingExpression.Activate(System.Object)+0x194
0036EACC 60097C49 PresentationFramework_ni!System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt)+0x38d
0036EB74 600C3D51 PresentationFramework_ni!System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean)+0x19
0036EB80 600C3D19 PresentationFramework_ni!MS.Internal.Data.DataBindEngine+Task.Run(Boolean)+0x31
0036EB94 600C3C36 PresentationFramework_ni!MS.Internal.Data.DataBindEngine.Run(System.Object)+0xb6
0036EBB0 600C2CBA PresentationFramework_ni!MS.Internal.Data.DataBindEngine.OnLayoutUpdated(System.Object, System.EventArgs)+0x1e
0036EBC0 61271CD8 PresentationCore_ni!System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()+0x154
0036EBF8 6127159E PresentationCore_ni!System.Windows.ContextLayoutManager.UpdateLayout()+0x926
0036ECF8 61277F4D PresentationCore_ni!System.Windows.ContextLayoutManager.UpdateLayoutCallback(System.Object)+0x19
0036ECFC 61277F28 PresentationCore_ni!System.Windows.Media.MediaContext+InvokeOnRenderCallback.DoWork()+0x10
0036ED00 61277EC2 PresentationCore_ni!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()+0x76
0036ED1C 6127785A PresentationCore_ni!System.Windows.Media.MediaContext.RenderMessageHandlerCore(System.Object)+0x8a
0036ED68 612777AA PresentationCore_ni!System.Windows.Media.MediaContext.RenderMessageHandler(System.Object)+0x6e
0036ED80 6274FE83 WindowsBase_ni!Unknown+0x53
0036EDA0 6274FE0C WindowsBase_ni!Unknown+0x9c
0036EDE8 62752C95 WindowsBase_ni!Unknown+0x8d
0036EE24 62752BF8 WindowsBase_ni!Unknown+0x38
0036EE2C 642F4D85 mscorlib_ni!System.Threading.ExecutionContext.runTryCode(System.Object)+0x51
0036F2D0 642F4C8A mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x6a
0036F2E8 642F7F92 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0x7e
0036F30C 642F7F04 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x2c
0036F328 62752B28 WindowsBase_ni!Unknown+0x68
0036F364 6274E7FE WindowsBase_ni!Unknown+0x15e
0036F3A8 6274E9D7 WindowsBase_ni!Unknown+0x63
0036F3F8 627500A6 WindowsBase_ni!Unknown+0xbe
0036F444 6274FFD5 WindowsBase_ni!Unknown+0x7d
0036F454 6274FE83 WindowsBase_ni!Unknown+0x53
0036F474 6274FDB2 WindowsBase_ni!Unknown+0x42
0036F4BC 6274E2CC WindowsBase_ni!Unknown+0xb4
0036F504 6274F8B8 WindowsBase_ni!Unknown+0x104*
许多线程只是针对该问题提供了一个临时解决方案,有人知道对自动化对等 API 的递归调用无效的根本原因有任何想法吗?
【问题讨论】:
我不知道,但很奇怪。 【参考方案1】:我意识到这是一个旧线程,但我在重新加载几个月前完成的项目后遇到了完全相同的问题。
唯一真正重要的变化是我安装了 RoboForm 进行试用,但它已经过期。
我可以非常轻松且一致地重新创建,卸载它,问题现在消失了。
【讨论】:
以上是关于根本原因:对自动化对等 API 的递归调用无效的主要内容,如果未能解决你的问题,请参考以下文章