Results 1 to 3 of 3

Thread: [RESOLVED] Access disposed object

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [RESOLVED] Access disposed object

    I am displaying a form, then closing it using the normal:

    this.Show();
    this.Close();

    But when I am trying to open it a second time I get this error:

    Code:
    Cannot access a disposed object.
    Object name: 'MyForm'.
    I have never gotten this before on other projects. Is it something I have missed?

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Access disposed object

    When you close the form, you've disposed of it, so you will need to re-instantiate it to open it again.

    If you want to use the form again, you could always use ShowDialog and then that would require that you dispose of the form manually when you're done with it.

    You can find more on the form.close method here: http://msdn.microsoft.com/en-us/libr...orm.close.aspx

  3. #3

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Access disposed object

    Oh I see. I solved it by doing as you said

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width