I have a List that is cleared out every so often. The code is exactly like this:
VisitorAgent[] toPersist;
List<VisitorAgent> v = (List<VisitorAgent>)state;
lock (v)
{
toPersist = v.ToArray();
v.Clear();
}
//further processing of toPersist objects
Today i just got an Argument exception which doesn't make sense to me unless there was a memory issue. But if that was the case, why not OOM exception? What could cause this exception when calling ToArray()?
System.ArgumentException: Destination array was not long enough. Check destIndex and
length, and the array's lower bounds.
I am using .NET 3.5 & C#.