From LSDevLinux
Revision as of 12:11, 21 January 2010 by Mayhewn (talk | contribs) (Categorize)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This documentation is a work in progress.

ManagedComBridge is a library the implements a special COM object, that can be used with libcom to Create Managed mono COM object in a Native running application.

Some example lines from the file.

# managed-com-bridge: MyDotNetClass
0490e147-f2d2-4909-a4b8-3533d2f264d0 TestComObject.dll TestComObject.MyDotNetClass

# managed-com-bridge: IMyDotNetInterface

This example shows a Managed declared interface IMyDotNetInterface and a Managed defined interface MyDotNetClass

And here is some example C++ code which shows it being used.

TestComObject::IMyDotNetInterface *ptrMyDotNetInterface = NULL;
if (S_OK != ::CoCreateInstance(TestComObject::CLSID_MyDotNetClass, NULL, CLSCTX_ALL, TestComObject::IID_IMyDotNetInterface, (void **)&ptrMyDotNetInterface))
 fprintf(stderr, "CoCreateInstance Failed\n");
 return 1;

You will also need to include the .tlh file for the COM object (so the C/C++ can know about IID ect..., when using MSVC one can just use a #import and name the type lib (.tlb))

So on Linux one has to generate a .tlh (type lib header) from the managed assembly one way of doing that is the following:

  • Copy managed .dll to a Windows machine.
  • Generate type lib (.tlb) from the .dll (I suggest using tlbexp.exe, although you could use Regasm.exe as well)
  • in a C++ file #import type lib and compile the C++ file.

for example #import "C:\TestComObject.tlb" named_guids raw_interfaces_only This should write a .tlh file in the Output Directory.

  • modify the .tlh file so that it works with libcom ** TODO Write better instructions for this step **