Microsoft KB Archive/307211

= You can configure the Unattended Execution option and the Retained In Memory option in the latest version of Msvbvm60.dll =

Article ID: 307211

Article Last Modified on 8/7/2007

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 3
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 4
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 5
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q307211





SUMMARY
You must turn on the Unattended Execution option and the Retained In Memory option before compilation to host a Microsoft Visual Basic Enterprise Edition for Windows 6.0 component (Microsoft ActiveX DLL) in a multi-threaded environment, such as Microsoft Transaction Server (Mtx.exe), Internet Information Services (Inetinfo.exe), COM+ (Dllhost.exe), and Microsoft SQL Server 7.0 or SQL Server 2000 (Sqlservr.exe). However, you may not know whether a component is going to be used in such an environment or you may forget to turn on the Unattended Execution option and the Retained In Memory option. To address this problem, the latest version of the Visual Basic runtime (Msvbvm60.dll) introduces a new feature that permits you to turn on the Unattended Execution option and the Retained In Memory option at run time. This article discusses how to configure these options and what to be aware of when you turn on these options at run time.



MORE INFORMATION
On computers with Msvbvm60.dll version 6.0.96.32 or later installed, you can configure the Unattended Execution option and the Retained In Memory option of Visual Basic 6.0 components (ActiveX DLLs) by using a configuration file. The configuration file must be located in the same folder as the EXE image file of the application.

The configuration file must have the same name as the EXE with the addition of a .cfg extension at the end of the file name. For example, if the host process is named c:\test\myapp.exe, the configuration file must be named c:\test\myapp.exe.cfg.

The configuration file must be a text file with the following structure: [Options] Unattended= Retained= The Visual Basic 6.0 runtime checks the options and then sets the options as follows:
 * 1) If a .cfg file is located in the application folder, a 1 value causes Visual Basic 6.0 runtime to set the option. A 0 value causes Visual Basic 6.0 runtime to use the value that is set at compile time. If the value for Unattended is 0, the value for Retained is treated as 0 regardless of how it is set in the .cfg file.
 * 2) If Visual Basic 6.0 runtime does not locate a .cfg file and you host the runtime in Microsoft Transaction Server (Mtx.exe), in Internet Information Services (Inetinfo.exe), or in COM+ (Dllhost.exe), both the options are turned on regardless of the settings at compile time. If the host process is anything else, the settings are based on the options that you select at compile time.



Even with a .cfg file, a Visual Basic 6.0 component that you intend to use in Internet Information Services, in COM+, or in any multi-threaded environment with a dynamic thread pool must not include any user interface elements. For example, the component must not include Visual Basic 6.0 forms or Visual Basic 6.0 controls.

Note A dynamic thread pool is a thread pool that repeatedly creates threads and repeatedly destroys threads.

The forms and the controls that are included with Visual Basic 6.0 and that are designed with Visual Basic 6.0 are intended to be used in applications that are single-threaded or in applications that are multi-threaded without a dynamic thread pool. If you use user interface elements in a multi-threaded environment with a dynamic thread pool, unpredictable behavior may occur, including deadlocks.

