Proper Declare/Dispose of Objects in VB.NET
Posted on 2012-08-28
I am working on an application that uses classes to open one to two forms simultaniously. The first execution of the aplication works fine and I can close the open forms, but upon executing a different menu option I am getting an "ObjectDisposedException" error.
I believe the problem is how I am closing/handling the Open/Close process so I wanted to ask for your assistance. I haven't shown any code, but want to use an analogy because I thing it would be shorter and better illustrate what I want to have happen.
I have two menus, one called Project and the other Designs. Both menus have "New" and "Open".
New will open two forms, Editor and Catalog. The user works with the entry and can view select entries with the Catalog. Once the user is inished he/she clicks close on the Editor and both the Editor and Catalog close. The Catalog cannot close until the Editor is closed.
Open differs from New in that the Catalog is opened first. In this case the user selects an entry which is saved to a variable. The Catalog form is closed and the Editor/Catalog are opened and the selected entry is displayed as with New above accept that it is an existing entry.
The closure of the Catalog with Open gives me the error I mentioned.
Given the analogy aboe can you give me an example of the code I would need to add when I close the Editor form. If you need to see portions of the actual code just let me know.
BTW as stated above I do want the Catalog to close in the Open menu option above and be re-opened with Editor rather then to leave it open if I can do that.