Announcement

Collapse
No announcement yet.

DLL will not unload...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DLL will not unload...

    Hi Everyone,

    I am using a PB DLL/6 created DLL in Visual Basic. When I run
    my project in the VB IDE the DLL loads but it appears that when
    I quit running my project the DLL stays loaded. This always
    occurs - not only if I break out of the VB program prematurely.

    Having the DLL remain in memory is a problem because when I restart
    running the program again the DLL retains its info from the last
    time thus returning error codes to me.

    Has anyone else noticed this type of behavior when using Win32
    DLLs in the VB IDE. If I quit VB the DLL unloads. It seems like
    the VB IDE is determining when the DLL should unload and not
    my program.

    I have confirmed that the DLL stays loaded between compiles by
    using a DLL spy program that lists running DLLs.

    Any help is appreciated.

    Thanks,




    ------------------
    Paul Squires
    mailto:[email protected][email protected]</A>
    Paul Squires
    FireFly Visual Designer (for PowerBASIC Windows 10+)
    Version 3 now available.
    http://www.planetsquires.com

    #2
    All the time.
    Be sure you attach your windowclasses to the dll, not the exe! (VB-IDE)

    Use a proper unload, not the stop button.
    Be sure? unload VB.

    ------------------
    hellobasic

    Comment


      #3
      It's been that way since VB3 and PB/DLL1.1, if a PB DLL is called with a declare then it stays resident until the VB IDE is closed

      ------------------

      Comment


        #4
        Okay, I have found a fix.

        In VB's unload event I call a function in my DLL (UnloadDLL). All
        that function does is use the DLL's hInstance handle in a call
        to the FreeLibrary API routine. The DLL unloads and is ready to
        be used again.

        All that is needed is for the VB programmer to remember to include
        this call in the unload event.

        Thanks,



        ------------------
        Paul Squires
        mailto:[email protected][email protected]</A>
        Paul Squires
        FireFly Visual Designer (for PowerBASIC Windows 10+)
        Version 3 now available.
        http://www.planetsquires.com

        Comment


          #5
          No, that not good.
          The DLL is kept loaded because VB claims a reference to it somehow.

          This is only when you have used a custom windowclass or *maybe* using a thread.

          If the control is correctly unloaded from the form, the DLL WILL unload properly in the IDE.

          Just be sure you terminate all 'connections' files etc..

          That VB loads your DLL is logical.

          I messed with this myself, i know it's something you do not clear up.
          Tip: there's no need to unregister a windowclass.


          ------------------
          hellobasic

          Comment


            #6
            Hi Edwin,

            My DLL is a "helper" DLL. It just contains many functions that
            are easier to perform in PB than VB. It does not contain any
            windows, dialogs, message pumps, threads or anything like that.

            The DLL does seem to unload because I used a DLL spy program that
            lists all running DLL's and when I call the unload function the
            DLL no longer shows in the list and I am able to restart the
            VB program without any problems.

            Maybe I am not understanding what it is you are trying to tell
            me. Sorry.



            ------------------
            Paul Squires
            mailto:[email protected][email protected]</A>
            Paul Squires
            FireFly Visual Designer (for PowerBASIC Windows 10+)
            Version 3 now available.
            http://www.planetsquires.com

            Comment


              #7
              If it's for internall use, fine.
              If you enable save files before run , you may encounter a GPF.

              It's a simple test, place a msgbox in your libmain detach.
              If it occurres while simply closing your app NOT using the stop button, it's all fine.


              ------------------
              hellobasic

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎