Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I was adding random points in my chart.
(Imports System.Windows.Forms.DataVisualization.Charting)
while saving in textfile.
And as data accumulated, I encounter this error:


Exception:Caught: Collection was modified; enumeration operation may not execute. (System.InvalidOperationException)
A System.InvalidOperationException was caught: |Collection was modified; enumeration operation may not execute|
Time: 10/21/2015 10:36:07 AM
Thread:No Name[1456]


I added Try Catch in every code but It does not show any error and graph has red cross in it. What happen?
Posted
Comments
Sergey Alexandrovich Kryukov 20-Oct-15 23:40pm    
I would like to see how did you manage to handle exception the way it did not handle anything. Too bad you did not demonstrate it. Be careful: not understanding how to handle exceptions can cost you a lot, so better learn it well.
—SA
NekoNao 21-Oct-15 2:00am    
it seems like my chart has a problem with background worker.
Sergey Alexandrovich Kryukov 21-Oct-15 2:35am    
We could help you only if we had a comprehensive issue description...
—SA

1 solution

> What happen?

You attempted to modify a collection while enumerating (iterating) through it. That's not permitted.

/ravi
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Oct-15 23:38pm    
Yes, as simple as that, a 5.
The analysis of what can happen if this rule is not enforced could be taken as a home exercise.
—SA
Matt T Heffron 21-Oct-15 13:14pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900