About once a month we came across a bizarre mistake that I have no explanation about. The error is this:
System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.List`1.Enumerator.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
Here is the code in which the error occurs. This method is called in the constructor of MyObject:
When an error occurs, it will happen in 100% of cases when this method is started (which is a lot), until I process the application pool that fixes it. This tells me that this has something to do with the caching part of it, but it still makes no sense to me, because as soon as I pull MyObjectList from the cache, it doesn't modify anything, but it seems like this is the only way an error can occur if MyObjectList was somehow modified and firstordefault occurred.
The error is so rare and unpredictable that we could not recreate it, so any help would be greatly appreciated.
source share