We used WPF Tookit DataGrid and .NET 3.5 for about 2 years. And we have two cases that throw an exception - "The recursive call to the automation method of the Peer API is invalid." He came out of a strange and stylish, very few computers have such a problem.
Case 1:
Drop-down list (WPF Tookit DataGrid as DropDown Content Management):
And this can be solved with:
protected override AutomationPeer OnCreateAutomationPeer() { return null; }
This solution from WPF Recursive Call for Automation API Peer API is not valid .
Case two:
WPF Tookit DataGrid has a Temlate column in which the cell template has a drop-down list (WPF Tookit DataGrid as a DropDown content control). It cannot be fixed by the solution above.
*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*
Many threads have only one solution to solve the problem. Is anyone aware of the Root cause of a recursive invocation of a Peer API automation method invalid?
source share