ArgumentExceptions and InvalidOperationExceptions when calling RadGridView.EndUpdate()

3 Answers 64 Views
GridView
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Stephan asked on 24 Nov 2023, 11:04 AM | edited on 24 Nov 2023, 11:05 AM

Hello,

we have an application using Telerik version 2021.3.1123.40. It is not the first time these errors were reportet, but I have no methode to reproduce it at the moment. The chain of Events for both errors is, that RadGridView.FilterChanged-Event is called, from there we call our method "UpdateProzessschritte" (UpdateProcessSteps), which does a BeginUpdate and EndUpdate of the grid. When EndUpdate is called, the 2 errors orccured under certain, unknown conditions.

  1. ERROR|TBM_HAProzessPlugin.MainForm|1|(null)| In Modul TBM|DNA - Digitaler Netzanschluss ist ein Fehler aufgetreten. System.InvalidOperationException: Die Auflistung wurde geändert. Der Enumerationsvorgang kann möglicherweise nicht ausgeführt werden.
       bei System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       bei System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       bei System.Collections.Generic.List`1.Enumerator.MoveNext()
       bei Telerik.WinControls.UI.DataGroup.<GetEnumerator>d__7.MoveNext()
       bei Telerik.WinControls.UI.GridViewGroupRowInfo.get_ChildRows()
       bei Telerik.WinControls.UI.GridViewRowInfo.HasChildRows()
       bei Telerik.WinControls.UI.GridTraverser.CanStepInHierarchy()
       bei Telerik.WinControls.UI.GridTraverser.StepInHierarchy()
       bei Telerik.WinControls.UI.GridTraverser.MoveNextCore()
       bei Telerik.WinControls.UI.GridTraverser.MoveNext()
       bei Telerik.WinControls.UI.GridTraverser.GoToRow(GridViewRowInfo row)
       bei Telerik.WinControls.UI.BaseGridNavigator.ProcessEventCore(GridViewEvent eventData)
       bei Telerik.WinControls.UI.BaseGridNavigator.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
       bei Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
       bei Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
       bei Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
       bei Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
       bei Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
       bei Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.GridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.MasterGridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.GridViewTemplate.EndUpdate()
       bei Telerik.WinControls.UI.RadGridView.EndUpdate()
       bei TBM_HAProzessPlugin.MainForm.UpdateProzessschritte(RadGridView radGridView, RadDiagram radDiagram, Dictionary`2 prozessDauerListe, List`1 schritte) in C:\Program Files (x86)\Jenkins\jobs\TBM_DNA_Digitaler_Netzanschluss_WP\workspace\TBM_HAProzessPlugin\src\Forms\MainForm.cs:Zeile 510.
       bei TBM_HAProzessPlugin.MainForm.rgvHAAkten_FilterChanged(Object sender, GridViewCollectionChangedEventArgs e) in C:\Program Files (x86)\Jenkins\jobs\TBM_DNA_Digitaler_Netzanschluss_WP\workspace\TBM_HAProzessPlugin\src\Forms\MainForm.cs:Zeile 442.

    [Translation]: Collection was modified; enumeration operation may not execute


  2. ERROR|TBM_HAProzessPlugin.MainForm|1|(null)| In Modul TBM|DNA - Digitaler Netzanschluss ist ein Fehler aufgetreten. System.ArgumentException: Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt.
       bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       bei System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       bei Telerik.WinControls.Data.GroupBuilder`1.Perform(IReadOnlyCollection`1 items, Int32 level, Group`1 parent)
       bei Telerik.WinControls.Data.GroupBuilder`1.get_Groups()
       bei Telerik.WinControls.Data.RadDataView`1.get_Groups()
       bei Telerik.WinControls.UI.GridViewInfo.Refresh()
       bei Telerik.WinControls.UI.GridViewInfo.get_ChildRows()
       bei Telerik.WinControls.UI.GridViewTemplate.get_ChildRows()
       bei Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage(Boolean initializeCollection)
       bei Telerik.WinControls.UI.ViewInfoTraverser.ChangeCollectionForward()
       bei Telerik.WinControls.UI.ViewInfoTraverser.MoveNextCore()
       bei Telerik.WinControls.UI.ViewInfoTraverser.MoveNext()
       bei Telerik.WinControls.UI.GridTraverser.MoveNextCore()
       bei Telerik.WinControls.UI.GridTraverser.MoveNext()
       bei Telerik.WinControls.UI.GridTraverser.GoToRow(GridViewRowInfo row)
       bei Telerik.WinControls.UI.BaseGridNavigator.ProcessEventCore(GridViewEvent eventData)
       bei Telerik.WinControls.UI.BaseGridNavigator.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
       bei Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
       bei Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
       bei Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
       bei Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
       bei Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
       bei Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
       bei Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.GridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.MasterGridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
       bei Telerik.WinControls.UI.GridViewTemplate.EndUpdate()
       bei Telerik.WinControls.UI.RadGridView.EndUpdate()
       bei TBM_HAProzessPlugin.MainForm.UpdateProzessschritte(RadGridView radGridView, RadDiagram radDiagram, Dictionary`2 prozessDauerListe, List`1 schritte) in C:\Program Files (x86)\Jenkins\jobs\TBM_DNA_Digitaler_Netzanschluss_WP\workspace\TBM_HAProzessPlugin\src\Forms\MainForm.cs:Zeile 510.
       bei TBM_HAProzessPlugin.MainForm.rgvHAAkten_FilterChanged(Object sender, GridViewCollectionChangedEventArgs e) in C:\Program Files (x86)\Jenkins\jobs\TBM_DNA_Digitaler_Netzanschluss_WP\workspace\TBM_HAProzessPlugin\src\Forms\MainForm.cs:Zeile 442.

    [Translation]: Item with Same Key has already been added

 

Do you have any ideas which causes could lead to this exceptions and how to fix it? Or is this a known problem which was already fixed in later versions?

3 Answers, 1 is accepted

Sort by
1
Dinko | Tech Support Engineer
Telerik team
answered on 24 Nov 2023, 11:50 AM

Hi Stephan,

Thank you for the provided stack trace. However, using only the trace I can't determine why this is happening on your side. I will need more information regarding your scenario so that I can try to reproduce it. Without reproducing this we cannot know what exactly to investigate and what exactly should be changed and how. 

In the past 2 years, we have fixed several exceptions in the control. For example: RadGridView: InvalidOperationException is thrown when a row is expanded and the AutoSize property is true. I am posting this as an example. I am not sure if this is related. However, the first step we need to do is to update our assemblies in the project to their latest version. This way we can check if these exceptions are fixed in one of the newer versions.

You can check the Download Product Files help article which shows how to navigate to the download page in your account. Try updating the assemblies and follow the same steps before the update to see if these exceptions occur again.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 24 Nov 2023, 04:04 PM

Hello Dinko,

thanks for your fast reply. We discuss an Update on monday with our development team.

Our scenario is very complex. We use a custom group predicate to sort our groups by the status-field of the row, similar like your example mentionen here https://docs.telerik.com/devtools/winforms/controls/gridview/grouping/custom-grouping . We also enabled grouping. Seems like the error occured after changing and reloading a single entity, updating the bindinglist. After that the grid fired "OnFilterChanged".

I keep you updated next week.

Regards,

Stephan

Dinko | Tech Support Engineer
Telerik team
commented on 27 Nov 2023, 11:59 AM

Thank you for considering the option to migrate to the latest version of our controls. In the meantime, I have tried to follow your steps. To simulate your scenario, I have created a sample project and bind the RadGridView to a BindingList. Custom group predicate is added and when the control is filtered, I am updating a value from the BindingList in the FilterChanged event wrapped in BeginUpdate() and EndUpdate() methods. So far I wasn't able to reproduce this exception. You could check my project and try to modify it to reproduce these exceptions and send it back to me for further investigation.

0
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 30 Nov 2023, 01:47 PM

Hello Dinko,

we decided to update our components, but that process will need some time. I am still trying to reproduce this error, but I wasn't able to do it for now.  

Regards,

Stephan

Tags
GridView
Asked by
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Stephan
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or