VB 6 退出时崩溃

发布于 2024-11-15 12:38:07 字数 1995 浏览 2 评论 0原文

我有一个旧版 vb6 应用程序在退出时崩溃 - 无论是作为可执行文件还是在 IDE 中。我怎样才能避免崩溃?

  • 我目前正在 form_unload 中卸载表单(除了 frmmain),释放所有 ADODB 记录集,将所有绑定集合设置为无。
  • 我尝试在 form_terminate 事件中设置SetErrorMode SEM_NOGPFAULTERRORBOX,但这并没有阻止错误的发生。
  • 我还检查了代码中是否实例化了子类,但没有发现任何子类。
  • 我已经检查了使用的 Microsoft 外部组件 - 它们是 ComponentOne flexgrid 8 拼写 8 和 ComponentOne sizer 控件。广泛的网络和论坛搜索没有发现任何与我的这些控件类似的已知问题。

如果我在实际执行任何操作之前关闭程序,则似乎不会出现此问题。然而,加载绑定控件似乎接近问题根源,尽管使用调试器反复单步执行,但问题的开始似乎“四处移动”。问题发生在编程退出、“X”和 IDE“结束”控件上 错误信息是 “0x77d042b8”处的指令引用了“0x055c9028”处的内存。内存无法“读取”。错误框中的标题是我的应用程序内部的工具提示(在不同时间有所不同) 我在单步执行代码时设置了中断 - 应用程序在 Form_Unload 事件的退出子行上崩溃

添加
我意识到我应该在原来的帖子中包含一些其他信息。当我完成它时,我感到非常疲倦和沮丧,很抱歉它很难阅读。
现在
1) 我确实安装了最新的服务包 (6),以及组件的最新版本
2)在我的VS2010 ide(位于同一服务器上)中进行调试,我得到了一个以OLEAUT32.dll开头的很长的堆栈转储,我更新了该DLL但发现没有变化
3)我实际上是通过远程桌面连接运行(并处理)该程序的。该程序在我的桌面以及用户终端服务器连接上崩溃。
4) 我运行的操作系统是Windows Server 2003
5)我正在运行的代码是
'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'  

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

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'  

6) I have added a "getout" routine in the start up module on the hope that will allow the form object to close cleanly this did not fix the issue
Thank you all so much for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱花落人离去 2024-11-22 12:38:07

看起来这个 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'  

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

'code'
SetErrorMode SEM_NOGPFAULTERRORBOX  
'code' 

8)在 getout 子函数的开头
9) 确认上次打开的表单已关闭
10)将此代码包含在 getout sub 的底部,以确保它可以关闭

'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'  

最后一部分,这相当于将木桩打入其心脏
感谢大家给予我的帮助,特别是 MarkJ 编辑了我最初提交的论坛标准 - 我会尽力在可能的情况下偿还

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

凉宸 2024-11-22 12:38:07

正在发生的事情是一些背景工作正在进行。最有可能的是,某个进程在发出 close() 后触发了由事件处理程序处理的异步代码。避免方法是隐藏表单,然后在完成 close 方法之前等待一段时间。要解决这个问题,您必须确定是什么在后台线程上触发工作。在经典 VB 中,这最终可能会很痛苦。

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.

猫九 2024-11-22 12:38:07

情况很糟糕。

  • 您是否使用最新的 Windows Service Pack、VB SP6 和最新版本的组件
  • 问题是发生在其他机器上还是只是您的机器上?如果这只是您的机器 - 购买另一台机器。
  • 尝试通过删除程序的某些部分直到它停止崩溃来追踪这个问题。然后将碎片放回原处,直到发生碰撞为止。这应该可以帮助您追踪涉及哪些组件或代码。程序是否工作并不重要,你只需要知道它在退出时是否崩溃即可。您可以注释掉或删除整个类、删除控件等等。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文