windows forms exception and i dont know why

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
im getting this error:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll

Additional information: Collection was modified; enumeration operation may not execute.

i have no controls on the forum. i have overriden the onPaint method and the OnPaintBackground method. in my own paint method im drawing a simulation to the screen. i have bots, to which i pass a graphics object and draw them. each time they move, i invalidate the form and redraw. when they start moving too much, i get the error above. any ideas?
 
Without code (hint hint ;) ) I would guess that you are putting some information that you use in a foreach loop, while at the same time, an item is added/removed from this collection.

But we can't do much more than guess without some code, at least the lines where the exception occurs.
 
im sorry for not checking back sooner. i found out what was wrong. i was calling a paint method from within a paint method ( i dont know why) but this was causing the exception. sorry for bothering you
 
Back
Top