SYMPTOMS
When using Visual Basic 6.0 ActiveX components in a multi-threaded environment, you should be aware of the following potential problems:
ActiveX DLL hosted in a multi-threaded client
- Access Violation inside MSVBVM60.DLL.
- Client enters a deadlock state.
You may see these two symptoms if a Visual Basic ActiveX DLL is hosted in a multi-threaded environment, for example, IIS, MTS, or a multi-threaded client, and the
Retain In Memory option is not enabled. To enable this option, follow the steps below:
- From Project menu, select Project Properties.
- On the General tab, make sure that the Threading Model is Apartment Threaded, then select the Unattended Execution and Retain In Memory checkboxes*.
- Save the project and compile the DLL.
*Note The
Unattended Execution option is not available if the project contains any user interface elements, such as forms or controls. The
Retain In Memory option is not available if
Unattended Execution is not selected.
Note Prior to Service Pack 3 for Visual Studio 6.0, it was possible to get an AV during process shutdown with Retain in Memory enabled. This has been fixed in the latest Visual Studio 6.0 service pack:
If an ActiveX DLL or UserControl project contains API declarations, you may experience deadlocks during process/thread shut down or object creation, even if the
Unattended Execution check box has been selected in the case of an ActiveX DLL.
To workaround this problem, you can use a Type Library instead of Declare in Visual Basic. For additional information on how to use a Type Library, click the article number%2 below
to view the article%2 in the Microsoft Knowledge Base:
189133 HOWTO: Make C DLL More Accessible to VB with a Type Library
ActiveX EXE accessed by a multi-threaded client or by multiple single- or multi-threaded clients
Runtime error '7': out of memory and sometimes followed by a disk operation error.
Run-time error '430': Class does not support Automation or does not support expected interface.
Run-time error '424': Object required.
Run-time error '-2147023170 (800706be)': Automation error. The remote procedure call failed.
Run-time error '-2147287010 (8003001e)': Automation error. This is a "A disk error occurred during a read operation." based on ErrLook.
Additional server processes (ThreadTest.EXE) are created even though the Instancing property of Class1 is marked MultiUse.
You may see the error messages listed above if you have an ActiveX EXE server with a thread pool greater than one (1), and a multi-threaded client or multiple single- or multi-threaded clients rapidly creating and destroying objects inside the server. To work around this problem, you can create an empty class in the local server and have the client keep a reference to it as shown in the "More Information" section below.