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.

-bill

/* C++ code */
void cppMain ()
{
        // Init Mono Runtme
        
        // Call managed InitManagedCOMFactory
        
        IUnknown* pObj;
        ManagedCOMFactoryCreateObject (CLSID_MyObj, &pObj);
        
        IFoo* pFoo;
        pObj->QueryInterface (IID_IFoo, (void**)&pFoo);


}

uint (*ManagedCOMFactoryCreateObject) (GUID*, IUnknown**);

void RegsterManagedCOMFactoryCreateObject (void* ptr)
{
        ManagedCOMFactoryCreateObject = ptr;    
}




/* C# code */

void InitManagedCOMFactory ()
{
        RegsterManagedCOMFactoryCreateObject (ManagedCOMFactoryCreateObject);   
}

uint ManagedCOMFactoryCreateObject (guid g, [MarshalAs (IUnknown)] out
object retObj)
{
        if (g == myGuid)
                retObj = new MyObject ();
}
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to