Click here to Skip to main content
15,908,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Everyone,

I created my application, but one form keep on giving me an error. I get this error when I close the form. All other forms are ok, and I have no idea what is going on....

The Error:

Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.

Collection was modified; enumeration operation may not execute.


I think is related to the mybase.dispose(dispose), but I have no idea how to fix this issue.

The system code is as follow:

VB
'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
Posted
Updated 5-Oct-10 14:51pm
v2

1 solution

what is components.Dispose()?

I think there could be something wrong.

If components is a disposable collection and you try to dispose items using for each loop, that can give you this error.

Provide more code, if this doesn't help.
 
Share this answer
 
Comments
Kalila 6-Oct-10 10:34am    
Well, this code is generated automatically in vb10, I did not created this. This is the code that runs the X on the top right corner of your form when you close the form. All my other forms are fine and do not give me the error, and the same code appears. That is why I am so confuse.

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