|
-
Jul 7th, 2004, 09:38 AM
#1
Thread Starter
New Member
Resolved disposing problem
Hello.
I'm having difficulty ending a program. When I try to end from the main form everything is fine, but if I can't get the program to properly end from a second open form. With all the ways of ending a program that I know I always get the following error:
An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll
Additional information: Cannot access a disposed object named "ListBox".
I don't have any objects named "ListBox." I have one listbox on the secondary form named "lbxRecentFiles," but I'm not trying to access it on exit. Any ideas?
Last edited by micned; Jul 7th, 2004 at 09:56 AM.
-
Jul 7th, 2004, 09:41 AM
#2
PowerPoster
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 7th, 2004, 09:45 AM
#3
Thread Starter
New Member
Wow, that was easy. Application.Exit worked. Can't believe I had so much trouble with that.
Thanks a million.
-
Jul 7th, 2004, 09:48 AM
#4
PowerPoster
Hi,
You're welcome. Sounds like you don't start your projects with
Application.Run
Don't forget to edit your first post and add "Resolved" to the thread title.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 7th, 2004, 09:55 AM
#5
Thread Starter
New Member
No I don't start with Application.Run. What is the advantage of that and what does it do? Would I just put in in the Load section of the main form?
In case you haven't noticed, I'm new to .NET. I'm just teaching myself. Thanks for your help.
-
Jul 7th, 2004, 11:19 AM
#6
PowerPoster
Originally posted by micned
No I don't start with Application.Run. What is the advantage of that and what does it do? Would I just put in in the Load section of the main form?
In case you haven't noticed, I'm new to .NET. I'm just teaching myself. Thanks for your help.
Hi,
The cleanest way to start a project is to make Sub Main the startup object (Right click on the project name in the Solution Explorer Window; click on Properties in the drop down window that appears: make sure the General section is selected in the window on the left: select Sub Main in the Startup box: click on Apply at the bottom of the window.)
In a Module (assuming your starter form is fclsFirst)
VB Code:
Public frm1 as New fclsFirst
Public Sum Main()
Application.Run(frm1)
End Sub
This removes most pitfalls when you refer to frm1 from another form.
Best of luck.
Last edited by taxes; Jul 7th, 2004 at 11:40 AM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|