Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. cannot-access-a-disposed-object

cannot-access-a-disposed-object

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyes2007
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • E eyes2007

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      E 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        E Offline
        E Offline
        eyes2007
        wrote on last edited by
        #3

        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 thanks

        help everyone NO ONE LIVES FOREVER

        C 1 Reply Last reply
        0
        • E eyes2007

          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 thanks

          help everyone NO ONE LIVES FOREVER

          C Offline
          C Offline
          ChandraRam
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups