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. C#
  4. 'System.ObjectDisposedException'

'System.ObjectDisposedException'

Scheduled Pinned Locked Moved C#
question
3 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.
  • D Offline
    D Offline
    dratti
    wrote on last edited by
    #1

    Sorry for another question, but Im stumped on this: Im getting the following exception when I close my application: An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll Additional information: Cannot access a disposed object named "MainForm". MainForm is the name of...my main form. It sounds like my main form is getting disposed for it actually should, but Im not explicitliy disposing it anywhere, and really dont have any idea where to look. Any ideas, or at least where to start? Thanks

    S C 2 Replies Last reply
    0
    • D dratti

      Sorry for another question, but Im stumped on this: Im getting the following exception when I close my application: An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll Additional information: Cannot access a disposed object named "MainForm". MainForm is the name of...my main form. It sounds like my main form is getting disposed for it actually should, but Im not explicitliy disposing it anywhere, and really dont have any idea where to look. Any ideas, or at least where to start? Thanks

      S Offline
      S Offline
      shaunAustin
      wrote on last edited by
      #2

      No problems with the questions... that's what these boards are for after all!! :-D Is it possible that you are either trying to access members of your form or objects created from it after the Application.Run(new Form1()); line in your Main() function. OR... do you have a timer which you have not stopped? It could be firing an event handler after the object which handles the event has been "disposed of"... Some things to look for at least! :) Shaun :-D ----------------------------------------------------------------------- Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!! :-D

      1 Reply Last reply
      0
      • D dratti

        Sorry for another question, but Im stumped on this: Im getting the following exception when I close my application: An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll Additional information: Cannot access a disposed object named "MainForm". MainForm is the name of...my main form. It sounds like my main form is getting disposed for it actually should, but Im not explicitliy disposing it anywhere, and really dont have any idea where to look. Any ideas, or at least where to start? Thanks

        C Offline
        C Offline
        CBoland
        wrote on last edited by
        #3

        When a form is closed, it disposes of itself. You may still have a valid reference to the form and it won't be null/nothing, but it is a useless reference: any access to it results in ObjectDisposedException. Make sure you aren't trying to access properties/methods after it has closed.

        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