Problem

Uncaught Exception in TreeListBox.ClearSelection()

Posted 8 months ago by Avatar John Dunn

During some drag/drop operations in my TreeListBox I get the following uncaught exception

Uncaught Exception : System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at ActiproSoftware.Windows.Controls.Grids.TreeListBox.ClearSelection()
   at ActiproSoftware.Windows.Controls.Grids.TreeListBox.AddToSelection(TreeNode treeNode, Boolean append, Boolean updateAnchor)
   at ActiproSoftware.Windows.Controls.Grids.TreeListBoxItem.OnPointerPressed(Object sender, InputPointerButtonEventArgs e)
   at ActiproSoftware.Windows.Input.InputAdapter.#doi(Object #xhb, InputEventArgs #yhb, InputPointerButtonKind #zYi)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   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.InputManager.ProcessInput(InputEventArgs input)
   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)

 My code isn't in the call stack but is there anything my code could be doing to cause this behavior?


Comments (8)

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

Nothing should normally be causing that on our end unless you perhaps are doing some other modification to the tree in another thread.  Are you perhaps modifying the tree in another thread?

Are you able to make a new simple sample project that shows this happening that you could email to our support address?  Then we could debug with that to see what's going on.  If you can, please make sure you remove the bin/obj folders from what you send and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support
Posted 8 months ago by John Dunn

No, there aren't any other threads involved. I can send you my existing application but narrowing it down to a simple case will take a little time.

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

We'd really need a new very simple app that just shows this problem.  Our next build is planned for a week or so out, so as long as you could get us something before that (in case code updates are needed), that would be ideal.  Thanks!


Actipro Software Support
Posted 8 months ago by John Dunn

I don't have a simple repro case yet but I do think I know what might be causing the issue. My tree of items can have replicated data in it

A
+ B
  + C
  + D
+ E
F
+ G
+ B
  + C 
  + D  

 The B is node is not a copy - it's the same object that occurs twice in the tree. This seems to cause the issue with just selecting things. I disabled drag and drop and by just selecting various items I can cause the issue.

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

Yes we do track our data behind the scenes with some Equals() checks.  So if you have an item that returns Equals() with another item in the tree, then that could certainly cause problems.  Perhaps you could wrap them in some other object when databinding in our tree to keep them from being equal?


Actipro Software Support
Posted 8 months ago by John Dunn

That would be quite a change to my application - is something that you never plan on supporting?

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA

Hi John,

Behind the scenes, we are making a flat list of all the items and that becomes the true items source of the control.  Doing this allows us to obtain very fast speed for the control.  That being said, since the control is designed specifically for heavy MVVM usage, there are cases where we are passed a simple data object and need to find a matching TreeNode (internal class) that wraps it in our flat list.  That process is where the equals comes into play.  If you have more than one data item that are equal, then we might end up grabbing the wrong TreeNode wrapper.  I'm not sure there's really anything we can change our internal design to help with that scenario.  I'm sorry but the only workaround is probably to ensure that the data items bound to the tree don't have equality.

That being said, if you can send a new simple sample project that reproduces the problems to our support address and reference this thread, we can debug with it to see if there is anything we can do.  Please remove any bin/obj folders from the ZIP you send and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support
Posted 8 months ago by John Dunn

I've reproduced using a simple example and created support ticket 33C-21C471B1-0018

Information The latest build of this product (2018.1 build 0672) was released 27 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.