PRB: Reference to ActiveX EXE is not released when calling a function inside the GlobalMultiUse class in Visual Basic 6.0 (277765)



The information in this article applies to:

  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP3
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0 SP4

This article was previously published under Q277765

SYMPTOMS

The ActiveX EXE process in Microsoft Visual Basic does not quit when the calling client releases the reference to it.

CAUSE

This problem occurs because the Visual Basic ActiveX DLL that references the GlobalMultiUse class is complied when the Retained in Memory option is enabled.

A client program starts a Visual Basic ActiveX EXE process by instantiating a MultiUse class inside the ActiveX EXE. The ActiveX EXE process then makes a call to a Visual Basic ActiveX DLL that was compiled when the Retained in Memory option was enabled. If this ActiveX DLL then uses a GlobalMultiuse class from a separate Visual Basic ActiveX DLL, the ActiveX EXE process does not unload from memory when the original calling client releases the reference to the ActiveX EXE.

WORKAROUND

To work around this problem, use one of the following methods:
  • Move the functions that are used in the GlobalMultiUse class to a standard Visual Basic module instead.
  • Do not compile the Visual Basic ActiveX DLL that references the GlobalMultiUse class when the Retained in Memory option is enabled.

STATUS

Microsoft is researching this problem and will post more information in this article when the information becomes available.

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a new Visual Basic ActiveX EXE project with one MultiUse class.
  2. Paste the following code in the MultiUse class:
    Public Function go() As Long
        'Call a method inside an in-process Visual Basic ActiveX DLL<BR/>
        'Multi-Use class 
        Set oObject = CreateObject("RIMDLL.clsRIMDLL")
        i = oObject.DoSomeWork()
        Set oObject = Nothing
    End Function
    						
  3. On the Project menu, click Properties.
  4. Type ActiveXTester in the Project Name box, and then click to select Unattended Execution.
  5. On the File menu, click Make ActiveXTester.exe to compile the project in an ActiveX EXE.
  6. In a separate instance of Visual Basic, create an ActiveX DLL project.
  7. On the Project menu, click Properties.
  8. Type GMUDLL in the Project Name box.
  9. Change the instancing property of the default class to GlobalMultiUse, and then paste the following function into that class:
    Public Function PublicFunction() As Long
        PublicFunction = 0
    End Function
    						
  10. On the File menu, click Make GMUDLL.DLL to compile the project in an ActiveX DLL.
  11. Start a third instance of Visual Basic, and then create an ActiveX DLL project.
  12. On the Project menu, click Properties.
  13. Type RIMDLL in the Project Name box, and then click to select the Retained in Memory and Unattended Execution check boxes.
  14. On the Project menu, click References, and then add a reference to the GMUDLL.DLL.
  15. Click Make GMUDLL.DLL on the File menu to compile the project in an ActiveX DLL.
  16. Paste the following code into the default class:
    Public Function DoSomeWork() As Long
        l = PublicFunction()
    End Function
    						
  17. Change the name of the default class to clsRIMDLL.
  18. To compile this project in a DLL, click Make RIMDLL.DLL on the File menu.
  19. Test the ActiveX EXE by running the following VBScript code:
    Set oActiveXEXE = CreateObject("ActiveXTester.Class1")
    lRet = oActiveXEXE.go()
    Set oActiveXEXE = nothing 
    						
You expect that the ActiveX EXE process will be unloaded from memory when the script is completed. However, it remains. If the RIMDLL.DLL is recompiled when the Retained in Memory option is not enabled, the problem does not occur.

Modification Type:MajorLast Reviewed:8/24/2004
Keywords:kbprb KB277765 kbAudDeveloper