This is a migrated thread and some comments may be shown as answers.

Index was out of range

4 Answers 612 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ola
Top achievements
Rank 1
Ola asked on 13 Nov 2017, 09:55 PM

See that over the years there has been many issues with "Index out of range". Is this a general issue that has not been resolved yet? We are starting to use a WPF-application in production and as the load increases we get more and more of these exceptions. Looks like it can happen when we remove and item from a RadObservableCollection (or a ObservableCollection bound to a RadTimeline) and add an item right afterwards. Maybe combined with many entries in the collection.

Is there a workaround?

Here is a callstack:

2017-11-13 16:34:38,704 [106:1] ERROR Tennotech.Hilding.Watchman.App - Unhandled exception: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
2017-11-13 16:34:38,714 [106:1] DEBUG Tennotech.Hilding.Watchman.App - Stacktrace:
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Telerik.Windows.Controls.ProjectedView`1.ObservableSourceListCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.CompositeCollection.OnContainedCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Windows.Data.CollectionContainer.OnContainedCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
   at System.Collections.ObjectModel.Collection`1.Remove(T item)
   at Tennotech.Hilding.Watchman.Utilities.MirroredRadList`2.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in C:\BuildAgent\work\a6c0493e3d7aa6b\Source\Tennotech.Hilding.Watchman.Utilities\MirroredRadList.cs:line 193
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
   at System.Collections.ObjectModel.Collection`1.Remove(T item)
   at Tennotech.Hilding.Watchman.Framework.Devices.GenericRecordingsSynchronizer.OnRecordingsUpdated(Object sender, ParameterizedEventArgs`1 eventArgs) in C:\BuildAgent\work\a6c0493e3d7aa6b\Source\Tennotech.Hilding.Watchman.Framework\Devices\GenericRecordingsSynchronizer.cs:line 174
   at System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
   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)

4 Answers, 1 is accepted

Sort by
0
Ola
Top achievements
Rank 1
answered on 14 Nov 2017, 01:52 PM

An update to the issue:

The ObservableCollection to which the item is added is part of a CompositeObservable, to which the ItemsSource of a RadTimeline is bound. The issue seems to be related Windows 7, we get the exception almost every time a new item is added. We think we have seen the issue on window 10 as well, but can not confirm it today.

0
Ola
Top achievements
Rank 1
answered on 14 Nov 2017, 02:32 PM
I mean CompositeCollection, not CompositeObservable.
0
Martin Ivanov
Telerik team
answered on 16 Nov 2017, 03:18 PM
Hello Ola,

I cannot classify this exception as a general issue in UI for WPF, but as a common exception in .NET. Mostly this happens when you try to reach an element in a collection by its index and the index is equal or bigger than the collection count.

About the specific scenario, I without your implementation I cannot tell what happens, and this is why I would ask you to send me some runnable code snippets here that demonstrates the exception. Alternatively, you can create a new project showing the issue and send it via the support ticketing system.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ola
Top achievements
Rank 1
answered on 16 Nov 2017, 03:25 PM

We have concluded that this only happens on Windows 7, and now our only customer with Windows 7 have upgraded to Windows 10, so from our perspective this has been resolved. We will never try running the RadTimline on Windows 7 again. :)

/Ola
Tags
General Discussions
Asked by
Ola
Top achievements
Rank 1
Answers by
Ola
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or