Results 1 to 6 of 6

Thread: Resolved disposing problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5

    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.

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Have you tried

    VB Code:
    1. Application.Exit
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5
    Wow, that was easy. Application.Exit worked. Can't believe I had so much trouble with that.

    Thanks a million.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5
    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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:
    1. Public frm1 as New fclsFirst
    2.  
    3. Public Sum Main()
    4.   Application.Run(frm1)
    5. 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
  •  



Click Here to Expand Forum to Full Width