VB 6 crash on exit

Iro*_*d83 4 vb6 crash exit

I have a legacy vb6 app that crashes on exit - both as an executable and in the IDE. How can I avoid the crash?

  • I am currently unloading the forms (except the frmmain) in form_unload, releasing all the ADODB RecordSets, setting all the boundcollections = nothing.
  • I have attempted to SetErrorMode SEM_NOGPFAULTERRORBOX in the form_terminate event and that has not stopped the error from occurring.
  • I have also checked for subclasses being instantiated in my code and found none.
  • I have checked into the components from outside Microsoft that are used - they are the ComponentOne flexgrid 8 spelling 8 and ComponentOne sizer control. An extensive web and forum search has not turned up any known problems similar to mine for these controls.

The issue does not seem to occur if I shut down the program before actually doing anything. However loading the bound controls seems to be near where the problem is rooted, in spite of repeatedly stepping with the debugger it seems that the start of the problem "moves around". The problem occurs with the programmatic exit, the "X" and the IDE "end" control The error message is The instruction at "0x77d042b8" referenced memory at "0x055c9028". The memory could not be "Read". The title in the error box is a tool tip (differing at different times) from inside my app I have put breaks when stepping through the code - the app crashes on the exit sub line at the Form_Unload event

ADDED
I realized that I should have included some other information with my original post. I was very tired and frustrated when I made it and sorry it was so difficult to read.
Now
1) I do have the latest service pack (6) installed, and the latest builds of the components
2) doing a debug in my VS2010 ide (which is on the same server) I got a very long stack dump beginning with OLEAUT32.dll, I updated that DLL but found no change
3) I am actually running (and working on) the program through a remote desktop connection. The program crashes on my desktop as well as on the users terminal server connections.
4) The OS I am running under is Windows Server 2003
5) the code I am running is
'code'

    Private Sub Form_Unload(Cancel As Integer)
        Set rsChild = Nothing
        Set rsCaseFile = Nothing
        ' many similar record sets closing
        ys.CloseConnection
        Set ys = Nothing
        UnloadAllForms (Me.Name)
        ' closeing bound collections 
        Set bndChild = Nothing
         Set bndAuth = Nothing
         ' more bound collections closed
         ' i had added the next two lines but it made no difference
         frmmain.close
         Set frmMain = nothing 
         getout
    end sub
    Public Sub UnloadAllForms(Optional FormToIgnore As String = "")
        Dim f As Form
        For Each f In Forms
            If Not f Is Nothing Then
                If f.Name <> FormToIgnore Then
                    Unload f
                    Set f = Nothing
                End If
            End If
        Next f   
    End Sub

'\code'  
Run Code Online (Sandbox Code Playgroud)

6)我在启动模块中添加了一个“getout”例程,希望能够让表单对象干净地关闭,但这并没有解决问题
非常感谢大家的帮助

Iro*_*d83 5

看来 bug 已经死了,杀戮分为 10 个部分
1) 非常小心地处理所有对象
2) 确认每个记录集在设置为空之前已关闭
3) 从最后一个表单关闭事件关闭每个表单
4) 设置最后一个表单 .visible = false 然后调用计时器 1 秒
5) 在最后一个表单卸载事件的底部添加了一个 getout 调用
6) 将 getout 放入模块中
7) 添加

'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'  
Run Code Online (Sandbox Code Playgroud)

到该模块中的声明
8) 调用该声明

'code'
SetErrorMode SEM_NOGPFAULTERRORBOX  
'code' 
Run Code Online (Sandbox Code Playgroud)

在 getout 子程序开始时
9) 确认最后一个打开的表单已关闭
10) 在 getout 子程序的底部包含此代码以确保它可以关闭

'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'  
Run Code Online (Sandbox Code Playgroud)

最后一部分有点相当于把木桩打进它的心脏,
谢谢大家给我的帮助,特别是 MarkJ 编辑了我最初提交的论坛标准 - 我会尽力在可以的时候偿还