Results 1 to 35 of 35

Thread: Application not closing properly [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Resolved Application not closing properly [RESOLVED]

    There's something weird happening on an application I made for a client.

    Each time he close the application, it still running in the task manager.

    In the IDE, it's closing properly.

    I know that when an application is not closing, it means something still running in the application. I used debug.print just because the unload to see what's running.

    I'm using the com port, which is closed, a timer, it's disabled and a DB connection which is closed too.

    I tried to use the "End" command to completely close the app on the unload. On the IDE, it still working, but on the .exe, I get a Windows error message saying the application encountered errors and had to be closed by Windows.

    How can I see why the application is not closing properly ??




    Added green "resolved" checkmark - Hack
    Last edited by Hack; Oct 13th, 2005 at 06:20 AM.

  2. #2
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Application not closing properly

    Are you unloading all your forms? Are you opening a form then hidding it b/c you might not be unloading that one?
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Application not closing properly

    Quote Originally Posted by space_monkey
    Are you unloading all your forms? Are you opening a form then hidding it b/c you might not be unloading that one?
    Even if he is not unloading all the forms etc. the End command should terminate the application.
    It seems more of a corrupted system file issue to me.


    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Application not closing properly

    End is yucky. Don't use it
    VB Code:
    1. Dim f As Form
    2. For Each f In Forms
    3. Unload f
    4. Next f
    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    Forgot to tell you, this is something I test with Debug.Print

    VB Code:
    1. Debug.Print Forms.Count

    It returns 1, so everything is okay for the forms

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Application not closing properly

    What about closing and destorying your objects (like recordset objects, connections objects, etc)? Is that being taken care of?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I always close recordsets and connections.

    I'll check if I forgot something, but I don't think that's the problem

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Application not closing properly

    In your first post you said this was an application you made for a client.

    Is this only happeing on his machine or it happening no matter where you run it?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I didn't try it on other computer.

    What I did now, I'm creating a txt file on MDIForm_Unload that show the state of DB connection, COM Port, # of Forms, ...

    This way, I'll see where's the problem

  10. #10
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Application not closing properly

    Gensor, can you post the code or something? So I can take a look at it? I had a problem like this becuase I was using the form resize but by accident, didnt spell the form name correct and it never closed when running the exe.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    Actually, I can't. I know it would be the best way, but first, it's a big application and second, it's in French, so all variables, functions and subs are in French and third, it's a question of privacy. I'm not allowed to show or give source code. My boss would'nt like me if I do that

  12. #12
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Application not closing properly

    Gensor,

    You know that's like going to the doctor and telling him:

    Doc, I have a pain and I don't like it... But I am not going to tell or show you where.

    And then expecting him to diagnose and fix the problem properly.

  13. #13
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Application not closing properly

    Nice analogy randem.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  14. #14
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Application not closing properly

    Quote Originally Posted by neicedover1982
    ..... but by accident, didnt spell the form name correct and it never closed when running the exe.
    Option Explicit will fix that... Always use Option Explicit !

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    randem

    If you did something really stupid and hurt yourself. You'll be too shy to tell it to someone, so, you'll say to the doctor where you're harm, but you'll never tell him how you did to hurt yourself!!

  16. #16
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: Application not closing properly

    somewhere in your code you have managed to create a circular reference - and this what is keeping your app running.

    your job - find that reference.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I don't understand what you mean by circular reference !!

  18. #18
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Application not closing properly

    Put a timer on each for for each minute..have it open the app.path & "\info.txt" for instance..

    then have it print the timers form and when you close your app, you will see which form(s) are hanging

  19. #19
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Application not closing properly

    Gensor,

    The doctor would have to see the wound, wouldn't he. You have to show us yours. Post some code or we are just guessing. When it could be obviously clear if we saw some code. Your code can't be so scrective that a excerpt of your code would cause a national security alert.

  20. #20
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Application not closing properly

    You might have missed something that was very easy to overlook. Posting some code can't hurt. Extra eyes can always help.

  21. #21
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: Application not closing properly


  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I don't mind to post some code, but for this problem, I would have to post all the application. Posting a part of the application won't help you!

  23. #23
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Application not closing properly

    Gensor,

    So posting none will help HOW?

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I thought you would know by experience what are the common problems when an application is not closing properly.

  25. #25
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Application not closing properly

    Gensor,

    Experience is what make us ask for the code. If everyone coded the same you would not have this problem in the first place. That is why we need to see actual code. Common problems have been given to you. Unfortunately, coders find new ways to create old errors.

  26. #26
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Application not closing properly

    Search for 'not closing' and you'll see that the answers are all the same. Usually requires posting the code in question, as we can't read minds.

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly

    I'll try to figure it out by myself.

    So this is thread is now resolved

  28. #28
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Application not closing properly [RESOLVED]

    Post back when you figure it out.

  29. #29

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly [RESOLVED]

    Okay

  30. #30
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Application not closing properly [RESOLVED]

    Gensor,
    Did you by anyway miss my post no. 3.
    I'm 99% sure the problem is not with your application, but with the OS/ extenal factors. The END statement terminates the application instantly & unconditionally (though I won't recomment using it). So whether it is a circular reference or resources not released, this problem shouldnot occur.
    The surest way to confirm what I said is to try your app on another system. In case the problem is still there, your program is to be blamed, incase the problem goes away your OS is to be blamed.

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  31. #31

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly [RESOLVED]

    Actually, I tried it first with a Windows 2000 computer. And now, I have a new computer which have Windows XP on it and I still got a GPF when ending the program with End.

  32. #32
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Application not closing properly [RESOLVED]

    Gensor,

    Never use end. It is only there to terminate a specific portion of your app not all of it. It basically there for novices. There are independent portion of you app that you can start active such as API calls, other dll's or objects. You must terminate all processes and objects before terminating your app. End just does not do it!!!!

  33. #33

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly [RESOLVED]

    I know, I usually don't use End.

    I only tried it to see if it would close correctly.

  34. #34
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Application not closing properly [RESOLVED]

    If you want to PM me with your email address, I'll reply with mine, and I will look at it, and keep it confidential. If I have any questions, I'll post them here, after PM'ing you with my thoughts.
    Let's see if we can solve the problem, and produce a good thread for others!

  35. #35

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Application not closing properly [RESOLVED]

    That's a good idea, but I want to wait first.

    I modified my application to create a log file to show me what is still open when the application unloads.

    If I don't find what's the problem with the log file, I'll PM you my e-mail.

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