'System.ObjectDisposedException'
-
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
-
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
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 yourMain()
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 -
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
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.