COM Interop works fairly well once you have tamed it.
1) Avoid static class members, as these are not supported by COM. Also avoid identifiers that just differ by casing.
2) Add the following attribute to the assembly (in
3) Create the corresponding Type Library file and register it using the
command as a post-build event (
project Properties -> Build Events -> Post-Build Events -> Command Line
regasm "$(TargetPath)" /tlb
Build the class library from VC++, let
. The file
will also be built.
4) Under VB6, register the reference to the Type Library:
Project -> References...
, then browse to the
file and check the checkbox next to the new entry in the list.
5) From then on, the Object Browser (F2) will show you the contents of the library, and autocompletion will be performed by the editor.
next to the
executable to work from the IDE. You will also need to copy it next to the compiled application if you plan to
7) Instantiating a class is achieved with:
Dim MyInstance As MyLib.MyClass
Set MyInstance = New MyLib.MyClass
You're done !
You may experience malfunctions and error messages at some stages. These can be due to dlls (run-time libraires, .NET framework or
) not being found in the search path.
Datatypes unsupported by COM also raise issues.