This is just an FYI; because I got so many hits on google for it.
I got the "infamous" 'Cannot Access Disposed Object.' error when I was attempting to open a form again after I had closed it.
The fix (even though it's annoying), is easy enough; but again it's managed code problems and weirdisms I still haven't changed my opinion that I won't be using MS .NET after this when I get my development box back to normal. BUT anyway the solution is self explanitory and very easy (and somewhat obvious)
I think what happens (without indepth knowledge of how 3.5 managed code is working.) The "variable" name declaration is associated to some pointer; and the pointer is either A not being used as the lookup and the Variable Name is, or B the collection is overriding the active declaration and not updating the Garbage Collection.
I know this because this code doesn't work.
When it gets to
the Application hickups with a very nice message, after you close the form down and try to reopen it, that says :
So, my thought is that the "IsDisposed" property runs some sort of function to determine the Garbage Collection state and does a collection, or updates the request for the collection to be done.
Either way, an FYI and heads up for a rather annoying little problem.
I got the "infamous" 'Cannot Access Disposed Object.' error when I was attempting to open a form again after I had closed it.
The fix (even though it's annoying), is easy enough; but again it's managed code problems and weirdisms I still haven't changed my opinion that I won't be using MS .NET after this when I get my development box back to normal. BUT anyway the solution is self explanitory and very easy (and somewhat obvious)
VB.NET:
Dim SomeForm = New Form1
If SomeForm.IsDisposed Then Return
SomeForm.Show()
I think what happens (without indepth knowledge of how 3.5 managed code is working.) The "variable" name declaration is associated to some pointer; and the pointer is either A not being used as the lookup and the Variable Name is, or B the collection is overriding the active declaration and not updating the Garbage Collection.
I know this because this code doesn't work.
VB.NET:
Dim SomeForm = New Form1
SomeForm.Show()
When it gets to
VB.NET:
SomeForm.Show()
Cannot access Disposed object.
So, my thought is that the "IsDisposed" property runs some sort of function to determine the Garbage Collection state and does a collection, or updates the request for the collection to be done.
Either way, an FYI and heads up for a rather annoying little problem.