views:

17

answers:

1

Hello,

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.

+2  A: 

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.

Hans Passant
I'm registering the assembly automatically with tlbexp, right? The /tlb option is reported as unrecognized by the compiler and the linker. Are you sure about that?
SoMoS
No, tlbexp only generates a type library, nothing is getting registered. The /tlb option is for Regasm.exe, not the compiler or linker. It puzzles me greatly that you didn't get that from my post.
Hans Passant
It has to be something related with here being a bit late. I've reread your post and I'm as puzzled as you :)
SoMoS