[Mono-dev] Creating Managed COM objects from C++ (on linux).
andreas.faerber at web.de
Sun Dec 21 10:31:21 EST 2008
Am 19.12.2008 um 22:27 schrieb Tom Hindle:
> I had to convert from a MonoObject to a COM interface pointer.
> The only way I could work out how to do this was by using some
> internal mono functions. (removing static from mono src files ect.)
>> comClassInstance = mono_object_new (m_domain, comClass);
>> if (comClassInstance == NULL)
>> fprintf(stderr, "Failed to create instance of %s.%s from assembly
>> %s\n", classNamespace.c_str(), className.c_str(),
>> return 1;
>> // Get object callable from C++
>> mono_init_com_types(); // Internal mono function
>> void *pCCW =
>> (comClassInstance); // Internal mono function
>> (void**)ppvObject); // Internal mono function
> I think I could replace
> with mono_lookup_internal_calls
> but I don't know how to get around the need to call
> mono_init_com_types() and cominterop_ccw_queryinterface().
Regarding the icall, you could just obtain the corresponding
MonoMethod* and execute it via mono_runtime_invoke.
For the other two, just check where they are called normally.
More information about the Mono-devel-list