error code on walkthrough

XanMag
25 Nov 2015, 03:17
I have no clue what this means, but it has been popping up when I run my walkthrough. It does not appear to disrupt my game however. Any clues?

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)

The Pixie
25 Nov 2015, 07:45
You get that error if you try to change a list (or a dictionary I guess) in a foreach loop - in particular remove an item. For example this will:
l = Split("one;two;three", ";")
foreach (s, l) {
if (s = "two") {
list remove (l, s)
}
}

XanMag
25 Nov 2015, 15:00
Will it cause a problem for my game play?

The Pixie
25 Nov 2015, 21:02
Potentially, yes. Presumably you had a good reason for removing the thing from the list, and if that does not happen that would be a bad thing.

Can you work out where it is? What is happening in the game when it appears? Does that indicate a script or function to look at?

On go Tools - Code view, and [Ctrl]-F and just search for "foreach"; if you do not have many, that could be the quickest way.

XanMag
26 Nov 2015, 05:19
I have zero "foreach" scripts (I did search in code view to confirm). I have never used them. Actually, I have no clue what they are or how they would work. I've never removed anything from a list or dictionary. It only appears when I play from my walkthrough. I click close and go about testing my game. I do not think it happens if I play the game from the beginning to the end, but then again, I am trying to avoid doing that for now because it takes such a long time to play to test without using the walkthrough.

EDIT: The last five or six times running the walk through I have not experienced an error message, so... I guess I just cross my fingers and hope for the best.

Thanks again, Pixie. :)

The Pixie
26 Nov 2015, 08:05
If it just happens on the walk through, but not when you do exactly the same things in the same order in play, then I would ignore it.

Do you use timers at all? Because walkthroughs happen so fast, they can behave differently when there are timers.

XanMag
26 Nov 2015, 14:47
Nope. No timers. Enough people bitched about the one timer I used in X1, so I decided against it! lol