Accidental usage exception of TreeListBox

Grids for WPF Forum

Posted 2 years ago by Sunshine - Appeon
Version: 22.1.2
Platform: .NET 6.0
Environment: Windows 11 (64-bit)
Avatar

In the process of using TreeListBox, the following exception pops up. According to stack information analysis, it seems to appear inside the control.

Stack info:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: 对 Automation Peer API 的递归调用无效。
   at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
   at MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer, AutomationPeer referencePeer)
   at System.Windows.Automation.Peers.AutomationPeer.RaisePropertyChangedEvent(AutomationProperty property, Object oldValue, Object newValue)
   at System.Windows.Automation.Peers.RangeBaseAutomationPeer.RaiseMaximumPropertyChangedEvent(Double oldValue, Double newValue)
   at System.Windows.Controls.Primitives.RangeBase.OnMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at ActiproSoftware.Internal.jKF.WsX()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.TextView.WMl(TextViewTextAreaLayoutEventArgs  )
   at ActiproSoftware.Internal.z5f.MJy()
   at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.TextView.get_VisibleViewLines()
   at ActiproSoftware.Windows.Controls.SyntaxEditor.Automation.Peers.EditorOutliningMarginAutomationPeer.GetChildrenCore()
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
   at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
   at System.Windows.Automation.Peers.AutomationPeer.AutomationPeerFromInputElement(IInputElement focusedElement)
   at System.Windows.Automation.Peers.AutomationPeer.RaiseFocusChangedEventHelper(IInputElement newFocus)
   at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
   at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   at System.Windows.UIElement.Focus()
   at ActiproSoftware.Windows.Controls.Grids.TreeListBoxItem.AdG(Object  , InputPointerButtonEventArgs  )
   at ActiproSoftware.Windows.Input.InputAdapter.u8G(Object  , InputEventArgs  , InputPointerButtonKind  )
   at ActiproSoftware.Windows.Input.InputAdapter.y8P(Object  , InputEventArgs  )
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   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)

Comments (2)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Which exact version/build are you using and which .NET platform are you targeting with your app?  We need that information to try and deobfuscate the stack trace.  Our initial attempt to deobfuscate didn't work based on the information in your original post.

We haven't heard of the "Recursive call to Automation Peer API is not valid" exception issue before, but after searching that on the web, we see other instances of people reporting it sometimes happening when there are controls in other data grid types of controls.  One common workaround people seem to suggest is taking one of the controls and returning null from its OnCreateAutomationPeer to prevent the peer from getting used.

If you can reproduce the issue in a new simple sample project, please send that to our support address and reference this thread.  We'll be happy to take a look and see if we can sort out what is causing it.  Be sure to exclude the bin/obj folders from the .zip you send.  Thanks!


Actipro Software Support

Posted 2 years ago by Sunshine - Appeon
Avatar

The control version is 22.1.2. Project target framework is .Net 6.0.

We're sorry that we can't provide an example of this problem, it's a scenario where it's hard to reproduce stably.

At present, I don't know what operation will cause this exception, but it is certain that this is an accidental phenomenon, which may be related to the timing of our code call

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.