Tutorial :Creating a C++ COM client for C# COM server



Question:

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?


Solution:1

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

Something like:

tlbexp ComServerProject.dll /out:ComServerProject.tlb  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »