I need to develop some classes that should be callable from VB6 with Managed C++ (C++/CLI).
I've developed first a sample in C# and I can use the assembly through COM without problems just using the setting "Register for COM interop" and "Make assembly COM visible" (and using the attribute [ClassInterface(ClassInterfaceType.AutoDual)] to make methods available at VB6.
After that I tried to translate the sample to C++/CLI without success. I've created the same class with the [ClassInterface(ClassInterfaceType.AutoDual)] attribute. I've set the "Embedded IDL" setting to specify the output TLB but the TLB is not generated automatically. If I use the tlbexp util over the generated DLL I get a tlb that can be imported at VB6 but when I try to create an instance I get an "ActiveX compoennt can't create object (429)"
What more do I need to do with the project to let it run?
Thanks in advance.
Not much to go on but you never mentioned registering the assembly. The C++ IDE doesn't have the "Register for COM interop" option. From the Visual Studio Command Prompt, run Regasm.exe on the assembly to get it registered. You need the /codebase option if you don't put the assembly in the GAC. And the /tlb option generates the type library, making tlbexp.exe unnecessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With