cannot-access-a-disposed-object
-
hi all i have two froms, frmnew and the other one is frmupdate. frmnew is set the very first form to open when the application run. both forms contains a menu bars having two buttons on them. one button for exit the application and the other button allows the other form to open(.show). the code is something like
Me.Close() Me.Dispose() Application.DoEvents() frmupdatemodified.Show()
the last line frmupdatemodified.Show() shows the error cannot-access-a-disposed-object. what is going wrong please tell to solve the problem. thanks in advance help everyone -
hi all i have two froms, frmnew and the other one is frmupdate. frmnew is set the very first form to open when the application run. both forms contains a menu bars having two buttons on them. one button for exit the application and the other button allows the other form to open(.show). the code is something like
Me.Close() Me.Dispose() Application.DoEvents() frmupdatemodified.Show()
the last line frmupdatemodified.Show() shows the error cannot-access-a-disposed-object. what is going wrong please tell to solve the problem. thanks in advance help everyonefrmupdatemodified has already been closed and disposed. When you dispose of it, set it to nothing, and then you can check if you need to reinitialise it.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
frmupdatemodified has already been closed and disposed. When you dispose of it, set it to nothing, and then you can check if you need to reinitialise it.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
hi christian thanks for reply i check it out, i am not disposing the frmupdate, and if i miss something can u tell me how can i figure it out. i tried this also but it doesn't work
Me.Close() Me.Dispose() Application.DoEvents() frmupdatemodified.Dispose() frmupdatemodified = Nothing frmupdatemodified.Show()
can you tell me how it can be done thankshelp everyone NO ONE LIVES FOREVER
-
hi christian thanks for reply i check it out, i am not disposing the frmupdate, and if i miss something can u tell me how can i figure it out. i tried this also but it doesn't work
Me.Close() Me.Dispose() Application.DoEvents() frmupdatemodified.Dispose() frmupdatemodified = Nothing frmupdatemodified.Show()
can you tell me how it can be done thankshelp everyone NO ONE LIVES FOREVER
eyes2007 wrote:
i check it out, i am not disposing the frmupdate, and if i miss something can u tell me how can i figure it out. i tried this also but it doesn't work
Me.Close() Me.Dispose() Application.DoEvents() frmupdatemodified.Dispose() frmupdatemodified = Nothing frmupdatemodified.Show()
You have only tried part of Christian's suggestion... you need to re-instantiate the form if you need to re-use it. At the .Show(), the object fromupdatemodified doesn't exist. Another point - the Me in the above sample... is it the form where you created the frmupdatemodified form object? In that case, since you have already called Me.Dispose, any objects created will also cease to exist.