Marshal.GetIDispatchForObject
Does anyone know if it is possible to create an IDispatch pointer out of a C# class to pass to a C++ object expecting an IDispatch pointer? I assume I have to create an interface, but how do I pass that interface as a pointer?
Code:
// C++ Executable expecting a COM IDispatch pointer
CCOW.ContextManager cm = new CCOW.ContextManager()
// C# dll
ContextParticipant .ContextParticipant icp = new ContextParticipant .ContextParticipant();
IntPtr iDispatchPtr = Marshal.GetIDispatchForObject(icp);
cm.JoinCommonContext(iDispatchPtr);
When I execute the above code the iDispatchPtr contains a value when running in debug, but when I try to use it in the C++ control it becomes NULL.
Any thoughts?
Thanks in advance!
Re: Marshal.GetIDispatchForObject