Components provide reusable code in the form of objects. A VB6 application that uses a component’s code, by creating objects and calling their properties and methods, is referred to as a client. And the DLL that exposes those components is referred as the server.
Components can run either in-process or out-of-process with respect to the clients that use their objects. An out-of-process component, or ActiveX EXE, runs in its own address space. The client is usually an application running in another process.
Client and out-of-process component
An ActiveX EXE usually define classes and these classes can have different instancing settings:
The VBUC will identify if your project is an ActiveX EXE. In your solution list it will mark its type as OleExe and the Reference Guid is the Guid that is used in other projects to reference this ActiveX DLL.
The VBUC provides at least 3 migration options:
The VBUC converts Visual Basic 6 ActiveX Dlls to .Net assemblies. By default the resulting .Net assemblies can be used only from managed code. If it is necessary use to these assemblies from non-managed code, this option should be selected in order to generate the .Net attributes required to expose these assemblies as COM Objects. For example: [ComVisible(true)].
In addition to the ComVisible attribute for the assembly members, the .Net project is also marked as a COM Visible.
The exposed classed will also have the necessary COM attributes added. For a source code example see here.
However in this approach no OutOfProcess support is provided. If you need this Dll to run out of process you can use a DllSurrogate
The DllSurrogate is setup in the Registry. After you register your assembly for COM
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe Assembly1.dll /codebase
you need to add two registry entries. For example:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[GuidAttribute("FF98BA94-FFFF-3D4F-9D11-BC6DE81D33EE")]
public class ComServer {
// Rest omitted
Then add two entries like the following:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AppID\{FF98BA94-FFFF-3D4F-9D11-BC6DE81D33EE}]
"DllSurrogate"=""
[HKEY_CLASSES_ROOT\CLSID\{FF98BA94-FFFF-3D4F-9D11-BC6DE81D33EE}]
"AppID"="{D698BA94-AEFF-3D4F-9D11-BC6DE81D330B}"
This approach is also useful if you want to migrate your project to 64 bit
but still use it from your 32bit legacy code VB6
This optional feature enables the conversion of ActiveX DLL/EXEs (with global variables) via a helper class (ComponentClassServer) that controls the instantiation of the generated class libraries.
ActiveX DLLs are converted to .Net using application domains and the instantiation of the components is archived using helper classes.
With this approach most of the ActiveX functionality is replicated in the converted code. For more details and sample code click here.
Converts ActiveX DLL/ and ActiveX EXEs to standard .Net assemblies (class library projects).
Remarks: All ActiveX are converted to native .Net assemblies. With this approach the converted code can be use only from manage code and the different VB6 ActiveX instantiation models (e.g MultiUse, GlobalMultiuse, etc) won’t be supported. |
The VBUC converts Visual Basic 6 ActiveX EXEs ActiveX DLL to standard .Net assemblies (class library projects).
One of the main differences between VB6 ActiveX and .NET assemblies is the way of how the component is instantiated (e.g MultiUse, GlobalMultiuse, etc). This initialization determines the lifetime behavior for the component. With this option the code is converted using pure .NET code and the VB6 ActiveX instantiation models won’t be supported.
8834 N Capital of Texas Hwy, Ste 302
Austin, TX 78759
Call us: +1 (425) 609-8458
info@wearegap.com