dcsimg
Results 1 to 20 of 20

Thread: VB6 program's Unload Me crashing in Windows 10

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Question VB6 program's Unload Me crashing in Windows 10

    Hello all,

    I am trying to solve an annoying problem with a legacy application, but every solution I've tried so far has been useless.

    The scenario is this: I am trying to install a VB6 application in a Windows 10 environment. (client's requirement, I am not exactly thrilled). I have tried this in 2 computers:

    The installation package finished smoothly, installation and configuration done with no problems as well. The thing is that if I load any child form and then try to unload it, the application crashes. I tried debugging one of them the JS-way: placing Message Boxes before and after the Unload Me function and one in the Error handler. Surprisingly, the Error Number is 0 but the program still crashes!

    However, if I start the program as Administrator FROM THE SHORTCUT, the forms unload without issues.

    Sooo, I think in order, these were my next steps:

    • Start the .exe directly as Administrator. Nope.
    • Check the Run As Administrator checkbox in the contextual menu (Properties - Compatibility) of the .exe. No good.
    • Create a .reg file to affect the HLKM\ ... \AppCompatFlags\Layers keys. Nada.
    • Affect both the HKLM AND HKCU keys. Thank you, next.
    • Check if some Recordset or variable was filled or active. Everything empty.
    • Tried Unload [name of the form] instead of Unload Me. Same result.


    Needless to say, installations in Windows XP (D: ) work perfectly, so I am thinking it's something to do with Win10's security policies OR the way the installation package is being created.

    Additional info:
    • No, code's not mine.
    • Code is not crashing (can test from A to Z in the IDE.)
    • I am not using manifests (yet.)
    • The client is using a waaaay old third party component without license, launching a "This application was created with an EVAL ~~~" Message Box every 0.5 seconds, but it is required for some functions, so stop using it is out of the question.


    If someone can at least guide me in the right direction, it will be very much appreciated.
    Do you know (or help me guess) what's the cause of all this and how can I prevent it?

    Thanks again,
    Tony.


    UPDATE: I made the application a Manifest about 30 minutes ago, but didn't work, just in case you were wondering.
    Last edited by oishii; Feb 6th, 2019 at 06:07 PM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,628

    Re: VB6 program's Unload Me crashing in Windows 10

    Clarification please:

    You said, "The thing is that if I load any child form and then try to unload it, the application crashes." You are talking about the legacy app I assume. By child form, are you saying that the app is MDI-form based and the child forms belong to the MDI? If not, can you clarify what you mean by "child form".

    You said, "However, if I start the program as Administrator FROM THE SHORTCUT, the forms unload without issues." Again, assuming you mean the legacy app? So, running elevated causes no problems? Sounds like the simple solution is to have the client/user run this app elevated -- but he/she may not have that option?

    If running app elevated fixes things, thinking along the lines as you. The app is attempting read/write or move memory somewhere they are not allowed to due to permissions.

    As far as the error goes, if memory is being moved via APIs, i.e., CopyMemory, then you can get a crash without error trapping triggering. In such a situation where user has insufficient rights reading something and uses "On Error Resume Next", then uses CopyMemory assuming all went right -- crash.

    I think it would be safe to say that there is not enough details. You say it isn't your code, but you have the code. You ma want to whip up test projects using that unlicensed control to see if you can narrow it down to that. Otherwise, I think we'll need to see some related code in order to help. At the very least, I think we would need to see the child form's Unload, Terminate events and its Declarations section to help.

    Is subclassing being used?
    You said no manifests are used? Are you 100% sure there is none in resource file? There is a known mainfest-related bug that can occur when vb-created compiled usercontrols are added to a project. For reference, jump to post #12 here: http://www.vbforums.com/showthread.p...ol-combination. In any case, you mentioned you might pursue manifests and that thread might be worth reviewing anyway
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Unhappy Re: VB6 program's Unload Me crashing in Windows 10

    LaVolpe,

    Thank you for your reply.

    I'll try to answer everything in order.

    - Yes, "[legacy app's] child forms" as in forms depending on the MDI (sometimes even calling other forms.)

    - Yes, I meant "[the legacy app] unloads without problems". Elevated state solves all this, but as users don't have administrator privileges and the program is installed for them by some guy, probably saying to this guy "just tell them to right-click it and select 'Run as Administrator'" is my last card to play.

    Quote Originally Posted by LaVolpe View Post
    Is subclassing being used?
    LOTS. MDI calls a form that has a button to call a form that opens a Message Box
    In the form I'm testing every form is being closed recursively (this was my first suspect, a form or a recordset still open.)

    - I am positive there are no manifests (Resource folder is empty and there is no .xml or .manifest files.) I am currently reading the post you sent and will read on manifests later.

    - Last but not least, the required code:


    Code:
    Private Sub cmdSalir_Click()
    
        On Error GoTo ErrHandler
    
        Dim frm As Form       'Identifica las formas a cerrar
        
        For Each frm In Forms
        If Not frm Is frmPoliza And Not frm Is MDIPrincipal Then
          'Si esta la pantalla de Asegurados sin reclamaciones a la vista, entonces no la cierra
          If Not frm Is frmAsegNoReclam And Not frm Is frmEndosoMedico Then _
             Unload frm
        End If
      Next frm
    ' limpiamos la variable que contiene la clave del plan
      gsPlan = ""
    ' limpiamos las variables que contienen conducto de envio y de pago
      gmstrInstPagoInd = ""
      gmstrCondEnv = ""
      
      Unload Me
      
    ErrHandler:                 'APM 2019-01-31: Captura el error que se provoca al descargar la forma
        If Err.Number <> 0 Then
        
                MsgBox "Ocurrió un error al cerrar: " & Err.Number & " - " & Err.Description, vbOKOnly
        End If
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
      If IsFormLoaded("frmCotiza") = False Then
        'Limpiamos variables para tomar nuevas cotizaciones
        bExisteCot = False
        gbInicio = True
    
      End If
        gblnRexpedicion = False
    End Sub

    I really appreciate your time helping me solve this. If there is anything I missed, please tell me.

    Regards,
    Tony.
    Last edited by oishii; Feb 6th, 2019 at 12:13 PM.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,628

    Re: VB6 program's Unload Me crashing in Windows 10

    I don't see anything in your posted code that stands out as a potential problem, unless any of those global variables are used in your subclassing routine that may be preventing it from unloading properly.

    But if the application runs correctly when elevated, I doubt subclassing has anything to do with this. The only thing I can think of is that somewhere in your subclassing routine, a call is made to log data to a folder/registry that may require elevated permissions -- causing an error, causing your subclassing routine to crash.

    Can you test that? Could you disable subclassing in a test copy and install/run the app to see if crashes still occur when run with standard permissions?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Re: VB6 program's Unload Me crashing in Windows 10

    Will do and keep you posted.



  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,921

    Re: VB6 program's Unload Me crashing in Windows 10

    What is your IsFormLoaded() function doing?

    What error does the crash show up as in the Event Log?

  7. #7
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: VB6 program's Unload Me crashing in Windows 10

    Quote Originally Posted by oishii View Post
    However, if I start the program as Administrator FROM THE SHORTCUT, the forms unload without issues.

    Sooo, I think in order, these were my next steps:

    [LIST][*]Start the .exe directly as Administrator. Nope.
    If I'm understanding correctly, these 2 statements seem to conflict. It works if you right-click the Shortcut and Run as Admin but not if you right-click the actual exe and Run as Admin? If that is true there must be some compatibility setting in the shortcut properties that's making it work.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Unhappy Re: VB6 program's Unload Me crashing in Windows 10

    Quote Originally Posted by dilettante View Post
    What is your IsFormLoaded() function doing?

    What error does the crash show up as in the Event Log?
    dilettante,

    Your answers below:

    Code:
    Public Function IsFormLoaded( _
      ByVal strForm As String) _
      As Boolean
      ' Comments  : Tests to see whether the default instance
      '             of a form is loaded
      ' Parameters: strForm - name of form to search for
      ' Returns   : True if the form is loaded, false otherwise
      ' Source    : Total VB SourceBook 6
      '
      Dim frm As Form
      Dim fResult As Boolean
      
      On Error GoTo PROC_ERR
    
      ' If a form is loaded, it will be in the Forms collection
      ' Search this collection to see if a form with the specified
      ' name is present.
      
      For Each frm In Forms
        If UCase(frm.Name) = UCase(strForm) Then
          fResult = True
          Exit For
        End If
      Next frm
      
      IsFormLoaded = fResult
    
    PROC_EXIT:
      Exit Function
    
    PROC_ERR:
      MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
        "IsFormLoaded"
      Resume PROC_EXIT
    
    End Function
    The Function is in a module, not in the form, if it's helpful.

    No error is shown, no log, nothing. The program just closes.

    Regards,
    Tony.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Re: VB6 program's Unload Me crashing in Windows 10

    Quote Originally Posted by topshot View Post
    If I'm understanding correctly, these 2 statements seem to conflict. It works if you right-click the Shortcut and Run as Admin but not if you right-click the actual exe and Run as Admin? If that is true there must be some compatibility setting in the shortcut properties that's making it work.
    topshot,

    Another of my hypothesis, but this one I don't know what (or where) to look for. Any ideas?

    Tony.

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,921

    Re: VB6 program's Unload Me crashing in Windows 10

    I was talking about a logged event, as in:

    Name:  sshot.png
Views: 638
Size:  14.6 KB

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,628

    Re: VB6 program's Unload Me crashing in Windows 10

    Also for oishi, is that true that it crashes if you run it as admin from the file itself, but running it as admin from a shortcut does not cause a crash?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: VB6 program's Unload Me crashing in Windows 10

    Quote Originally Posted by oishii View Post
    Another of my hypothesis, but this one I don't know what (or where) to look for. Any ideas?
    Right-click the shortcut, select Properties and then see if anything on the Compatibility tab is checked.

  13. #13

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Re: VB6 program's Unload Me crashing in Windows 10

    Went and came.

    LaVolpe: No luck taking all the subclassing. Yes, running it as an Admin from the shortcut doesn't cause a crash, but running it as an Admin from the exe does.

    topshot: Nothing is checked. Clean install.

    dilettante: The Event log just shows ALL the "EVAL version" events, as errors. However, I tried letting the form load, waiting a minute, and then unload. The last error was about the evaluation component, so if the unlicensed component is not coping correctly with unloading while not having elevated rights I **might** have a big situation here...

    Will try to chase the guy with the sole virtual machine with license, and see what happens. Thank you all.

  14. #14
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,564

    Re: VB6 program's Unload Me crashing in Windows 10

    The Shortcut to the .exe is on the User's Desktop (we assume), but it might help if you posted the full path to where the .exe actually got installed.

  15. #15

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Re: VB6 program's Unload Me crashing in Windows 10

    jdc2000,

    It's in the Windows Menu, actually, but the path to the exe is

    C:\Program Files (x86)\Emisor\Emisor.exe

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,628

    Re: VB6 program's Unload Me crashing in Windows 10

    Quote Originally Posted by oishii View Post
    LaVolpe: No luck taking all the subclassing. Yes, running it as an Admin from the shortcut doesn't cause a crash, but running it as an Admin from the exe does.
    That's odd. As mentioned earlier by others, compare the compatibility tab of both the shortcut and the actual exe

    And this may sound stupid, we all make dumb mistakes... Ensure the shortcut is pointing to the same exe you think it is pointing to. In the shortcut's "Shortcut" tab, click on the button "Open File Location" and ensure the folder that opens is the same as the exe you are right clicking on.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #17
    Lively Member
    Join Date
    May 2017
    Posts
    76

    Re: VB6 program's Unload Me crashing in Windows 10

    Hi, A couple of (wild?) things to check/try:
    1) Does the shortcut maybe have a "Start In" folder specified.
    2) "Administrator" i- are you running shortcut by right-click and run as, or is Run As set in the shortcut properties? Any difference between those two?

  18. #18
    Lively Member
    Join Date
    May 2017
    Posts
    76

    Re: VB6 program's Unload Me crashing in Windows 10

    *Duplicate Post* Admins delete pls?

  19. #19

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Unhappy Re: VB6 program's Unload Me crashing in Windows 10

    Sorry, lunch break.

    The shortcut is pointing to the actual executable. No problems here.

    However, it is working if I do Right-click - Run As, but it isn't if I set the Run As property to the shortcut.


    This is getting odder and odder...

  20. #20

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    10

    Re: VB6 program's Unload Me crashing in Windows 10

    So I told the client about this issue, and decided that if having an unlicensed third party dll is causing this much trouble it would be better to have the program virtualized in XP better than adapted to x64. Not the closing I wanted, but a closing after all.

    Thank you all for your efforts.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width