I'm getting the following exception when trying to clear a list.
System.IndexOutOfRangeException occurred
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=mscorlib
StackTrace:
at System.Array.Clear(Array array, Int32 index, Int32 length)
at System.Collections.Generic.List`1.Clear()
at SystemFilterFactory.ResetSystemFilters() in d:\Source\SystemFilterFactory.cs:line 57
InnerException:
The real exception wasn't being shown which is the base of that list is giving the following exception
Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
I actually ended up finding the cause from this post just before posting my question LIST<> AddRange throwing ArgumentException
However that took quite a bit more searching since i wasn't expecting the real problem to be with the list.
It turns out that since List is not thread safe, doing operations on the list where it will be changed in size on multiple threads at the same time can make it so that nothing on that list works correctly.
So for doing operations on the list make sure that you are doing it in a thread safe way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With