Declined
Last Updated: 27 Jun 2018 10:14 by ADMIN
Grégory
Created on: 27 Nov 2017 16:58
Category: GridView
Type: Bug Report
2
FIX. RadGridView - throws exception "Collection was modified; enumeration operation may not execute"
I have a GridView (Winforms v. 2017.3.1017.40, same problem with 2017.2.502.40) configured as on the attached screenshot (made some groups, made a search, and used the "excel-like" filter on a column to uncheck some values).

Then I try to click on some column headers to sort the grid.
After a few clicks, I get this error :
InvalidOperationException: La collection a été modifiée ; l'opération d'énumération peut ne pas s'exécuter.

I got different stacktrace with the same error :
InvalidOperationException: La collection a été modifiée ; l'opération d'énumération peut ne pas s'exécuter.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at Telerik.WinControls.UI.DataGroup.<GetEnumerator>d__0.MoveNext()
   at Telerik.WinControls.UI.GridViewGroupRowInfo.get_ChildRows()
   at Telerik.WinControls.UI.GridViewRowInfo.HasChildRows()
   at Telerik.WinControls.UI.PrintGridTraverser.CanStepInHierarchy()
   at Telerik.WinControls.UI.GridTraverser.StepInHierarchy()
   at Telerik.WinControls.UI.GridTraverser.MoveNextCore()
   at Telerik.WinControls.UI.GridTraverser.MoveNext()
   at Telerik.WinControls.UI.GridViewSearchRowInfo.worker_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

-----

InvalidOperationException: Failed to compare two elements in the array. ---> NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.GridViewRowInfoComparer.CompareRows(GridViewRowInfo x, GridViewRowInfo y, SortDescriptorCollection context)
   at System.Collections.Generic.ArraySortHelper`1.InternalBinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)


   --- End of inner exception stack trace ---
   at System.Collections.Generic.ArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Collections.Generic.List`1.BinarySearch(Int32 index, Int32 count, T item, IComparer`1 comparer)
   at Telerik.Collections.Generic.HybridIndex`1.PerformWithQuickSort()
   at Telerik.Collections.Generic.HybridIndex`1.get_Items()
   at Telerik.Collections.Generic.Index`1.GetEnumerator()
   at Telerik.WinControls.Data.GroupBuilder`1.Perform(IReadOnlyCollection`1 items, Int32 level, Group`1 parent)
   at Telerik.WinControls.Data.GroupBuilder`1.get_Groups()
   at Telerik.WinControls.UI.GridViewInfo.Refresh()
   at Telerik.WinControls.UI.GridViewInfo.get_ChildRows()
   at Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage(Boolean initializeCollection)
   at Telerik.WinControls.UI.ViewInfoTraverser.ChangeCollectionForward()
   at Telerik.WinControls.UI.ViewInfoTraverser.MoveNextCore()
   at Telerik.WinControls.UI.ViewInfoTraverser.MoveNext()
   at Telerik.WinControls.UI.GridTraverser.MoveNextCore()
   at Telerik.WinControls.UI.GridTraverser.MoveNext()
   at Telerik.WinControls.UI.BaseGridNavigator.NavigateToRow(GridViewRowInfo row, Boolean select)
   at Telerik.WinControls.UI.BaseGridNavigator.ProcessViewChangedEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.BaseGridNavigator.ProcessEventCore(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
   at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
   at Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
   at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
   at Telerik.WinControls.Data.RadDataView`1.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnNotifyPropertyChanged(String propertyName)
   at Telerik.WinControls.UI.GridViewSortDescriptorCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.SortDescriptor.set_Direction(ListSortDirection value)
   at Telerik.WinControls.UI.GridViewColumn.Sort(RadSortOrder sortOrder, Boolean multiSortMode)
   at Telerik.WinControls.UI.GridHeaderCellElement.Sort(RadSortOrder sortOrder)
   at Telerik.WinControls.UI.GridHeaderRowBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at Telerik.WinControls.UI.RadGridView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

------

InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at Telerik.WinControls.UI.DataGroup.<GetEnumerator>d__0.MoveNext()
[...]
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Alto.Client.Controls.Dispatch.DispatchResources.DeliveryPointFilterManager.get_DeliveryPointsVisible() in d:\Builds\45153\Alto\Alto.Prod\src\Alto\Alto.Client\Controls\Dispatch\DispatchResources\DeliveryPointFilterManager.cs:line 38
   at Alto.Client.Controls.Dispatch.DispatchResources.UcDeliveryPoint.get_Title() in d:\Builds\45153\Alto\Alto.Prod\src\Alto\Alto.Client\Controls\Dispatch\DispatchResources\UcDeliveryPoint.cs:line 1520
   at Alto.Client.Controls.Dispatch.DispatchResources.UcDeliveryPoint.updatePanelTitle() in d:\Builds\45153\Alto\Alto.Prod\src\Alto\Alto.Client\Controls\Dispatch\DispatchResources\UcDeliveryPoint.cs:line 543
   at Alto.Client.Controls.Dispatch.DispatchResources.UcDeliveryPoint.onFilterChanged(Object sender, GridViewCollectionChangedEventArgs e) in d:\Builds\45153\Alto\Alto.Prod\src\Alto\Alto.Client\Controls\Dispatch\DispatchResources\UcDeliveryPoint.cs:line 547
   at Telerik.WinControls.UI.GridViewCollectionChangedEventHandler.Invoke(Object sender, GridViewCollectionChangedEventArgs e)
   at Telerik.WinControls.UI.RadGridView.OnFilterChanged(Object sender, GridViewCollectionChangedEventArgs e)
   at Telerik.WinControls.UI.EventDispatcher.RaiseEvent[T](Object eventKey, Object sender, T args)
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.Collections.Generic.NotifyCollection`1.InsertItem(Int32 index, T item)
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.InsertItem(Int32 index, FilterDescriptor item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at Telerik.WinControls.UI.GridViewDataColumn.SetFilterDescriptor(FilterDescriptor value)
   at Telerik.WinControls.UI.GridHeaderCellElement.filterPopup_FilterConfirmed(Object sender, EventArgs e)
   at Telerik.WinControls.UI.BaseFilterPopup.OnFilterConfirmed()
   at Telerik.WinControls.UI.RadListFilterPopup.OnButtonOkClick(EventArgs e)
   at Telerik.WinControls.UI.RadListFilterPopup.ButtonOK_Click(Object sender, EventArgs e)
   at Telerik.WinControls.RadElement.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e)
   at Telerik.WinControls.RadElement.DoClick(EventArgs e)
   at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
   at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

----

InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at Telerik.WinControls.UI.DataGroup.<GetEnumerator>d__0.MoveNext()
   at Telerik.WinControls.Data.GroupBuilder`1.Perform(IReadOnlyCollection`1 items, Int32 level, Group`1 parent)
   at Telerik.WinControls.Data.DataItemGroup`1.get_Groups()
   at Telerik.WinControls.UI.DataGroup.get_Groups()
   at Telerik.WinControls.UI.GridViewTemplate.InvalidateSummaryRowsCore(DataGroup group, Boolean invalidateChildren)
   at Telerik.WinControls.UI.GridViewTemplate.InvalidateSummaryRowsCore(DataGroup group, Boolean invalidateChildren)
   at Telerik.WinControls.UI.GridViewTemplate.InvalidateGroupSummaryRows(DataGroup group, Boolean invalidateChildren)
   at Telerik.WinControls.UI.GridViewTemplate.RefreshSummaryRowsInGroup(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.UI.GridViewTemplate.RefreshAggregates(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
   at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
   at Telerik.WinControls.Data.RadDataView`1.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnNotifyPropertyChanged(String propertyName)
   at Telerik.WinControls.UI.GridViewSortDescriptorCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.WinControls.UI.GridViewSortDescriptorCollection.RemoveItem(Int32 index)
   at Telerik.WinControls.UI.GridViewColumn.Sort(RadSortOrder sortOrder, Boolean multiSortMode)
   at Telerik.WinControls.UI.GridHeaderCellElement.Sort(RadSortOrder sortOrder)
   at Telerik.WinControls.UI.GridHeaderRowBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at Telerik.WinControls.UI.RadGridView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

3 comments
ADMIN
Dimitar
Posted on: 27 Jun 2018 10:13
Hi Grégory,

The scenario description, stack trace and screenshot appear to be related to the following feedback item: https://feedback.telerik.com/Project/154/Feedback/Details/245938-fix-radgridview-having-groups-filters-sort-descriptors-and-search-query-in-t 

The observed exception can be reproduced by the asynchronous search in some very specific cases. The comments in the other item provide additional information on why this might happen. We have decided to handle this scenario by introducing a new IsSearchAsync property which is released in the R2 2018 SP1 version of the controls. We have also updated the Search Row documentation: https://docs.telerik.com/devtools/winforms/gridview/rows/search-row. In your actual project please set the RadGridView.IsSearchAsync property to false. In case you keep experiencing the issue please open a support ticket and let us know how it can be reproduced.

Regards,
Dimitar
ADMIN
Peter
Posted on: 06 Dec 2017 11:26
The provided stack trace is greatly appreciated. However, following the provided information, We are unable to reproduce the issue you are facing.  Could you please specify the exact steps how to reproduce the problem? Thank you in advance. 
Grégory
Posted on: 27 Nov 2017 16:59
Forgot the attachment.
Attached Files: