locked
Cannot Access a Disposed Object RRS feed

  • Question

  • Hi,

    I have a WIndows forms app in C# using VS2005 under development. When I load a child form from my main app, form, it loads and runs fine. If I close it and then try to open it again it gives me  an unhandled exception, Cannot access a Disposed Object.

    Not sure what to make of this.

    Any help would be appriciated.

    Thanks

    Jeff

    Friday, November 3, 2006 9:35 PM

Answers

  • A form automatically disposes itself and its controls when it closes.  Make sure you use the "new" operator to create a fresh new instance each time you display this form to avoid this error.

    Friday, November 3, 2006 9:42 PM

All replies

  • A form automatically disposes itself and its controls when it closes.  Make sure you use the "new" operator to create a fresh new instance each time you display this form to avoid this error.

    Friday, November 3, 2006 9:42 PM
  • Hi nobugz,

    You were correct. That pretty much was what it was.

    Thanks

    Jeff

    Friday, November 3, 2006 9:45 PM