[Mono-dev] Creating Managed COM objects from C++ (on linux).
billholmes54 at gmail.com
Fri Dec 19 17:07:53 EST 2008
We have dealt with this by registering a global class factory method
(that is implemented in C#) with native C++ code.
I assume you are hosting the mono runtime?
Take a look at the poor code example below and see if that gives you the idea.
/* C++ code */
void cppMain ()
// Init Mono Runtme
// Call managed InitManagedCOMFactory
ManagedCOMFactoryCreateObject (CLSID_MyObj, &pObj);
pObj->QueryInterface (IID_IFoo, (void**)&pFoo);
uint (*ManagedCOMFactoryCreateObject) (GUID*, IUnknown**);
void RegsterManagedCOMFactoryCreateObject (void* ptr)
ManagedCOMFactoryCreateObject = ptr;
/* C# code */
void InitManagedCOMFactory ()
uint ManagedCOMFactoryCreateObject (guid g, [MarshalAs (IUnknown)] out
if (g == myGuid)
retObj = new MyObject ();
More information about the Mono-devel-list