VB 6 crash on exit

六眼飞鱼酱① 提交于 2019-12-03 20:11:46

It appears that the bug is dead, the kill was in 10 parts
1) very carefully disposing of all objects
2) confirming that each recordset was closed before it was set to nothing
3) closing each form from the last forms close event
4) set the last form .visible = false then called a timer for 1 second
5) added a getout call to the bottom of the last forms unload event
6) put the getout in a module
7) added

'code'
Private Declare Function SetErrorMode Lib "kernel32" ( _
   ByVal wMode As Long) As Long  
Private Const SEM_FAILCRITICALERRORS = &H1  
Private Const SEM_NOGPFAULTERRORBOX = &H2  
Private Const SEM_NOOPENFILEERRORBOX = &H8000&  
'code'  

to the declarations in that module
8) called that declaration with

'code'
SetErrorMode SEM_NOGPFAULTERRORBOX  
'code' 

at the start of the getout sub
9) confirmed that the last open form was closed
10) included this code at the bottom of the getout sub to make sure it could close

'code'  
    Dim tstart As Date  
    tstart = TimeValue(Now())  
    Dim i As Integer  
    i = 0  
    Do While (DateAdd("s", 3, tstart)) > TimeValue(Now())  
        For i = 0 To 1000  
            i = i + 1  
        Next  
        i = 0  
    Loop   
   ' endtask("PLacements") 

    End  
'code'  

that last part was sorta the equivalent of driving wooden stake into its heart
thank you all for the help you have given me and specially MarkJ for editing my original submission to forum standards - I'll try and pay it back when I can

What is happening is there is some background work going on. Most likely some process fired off asynch code that is being handled by an event handler AFTER a close() has been issued. The avoid method would be to hide the form and then wait for a bit before finishing the close method. To fix it, you have to determine what is firing off work on a background thread. In classic VB, this can end up being painful.

A nasty situation.

  • Are you on the latest Windows service packs, VB SP6 and the latest builds of the components?
  • Does the problem happen on other machines or is it just your machine? If it's just your machine - buy another machine.
  • Try to track this down by taking pieces of the program away until it stops crashing. Then put pieces back in until it does crash. This should help you track down which components or code are involved. It doesn't matter whether the program works, you just need to know whether it crashes on exit. You can comment out or delete whole classes, delete controls, anything.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!