views:

64

answers:

1

I have a C# ComServerProject that implements an out-of-proc COM server, and I've selected the option "Make assembly COM-visible" on server project's "Assembly Information" dialog. In the same solution I have a C++ ComClientProject that should use the COM interface defined in ComServerProject. However, I don't know how to actually use the interface defined in the server in my C++ client.

All of the Google search results say that you should do #import "ComServerProject.tlb" to import the type library from the COM server. But there is no .tlb file created during the build! I also tried checking the "Register for COM interop" box on the Build tab of the server project properties, but it still didn't create a .tlb file. Plus, it required me to run VS elevated, which I would like to avoid.

How can I get VS2010 to actually create whatever files are necessary to have a usable COM server?

+1  A: 

Use Tlbexp on the generated assembly to create the .tlb.

Something like:

tlbexp ComServerProject.dll /out:ComServerProject.tlb
Ando
Do I need an explicit post-build step for that, or can I somehow convince VS to do it for me?
JSBangs
I am not aware of any way of getting VS to call tlbexp without resorting to a post build step.
Ando
@Ando, you can: in Visual Studio 2010, tick the "Register for COM interop" box under "Build" for the assembly.
Gravitas