I am trying to aggregate a .net comvisible object in another COM object. I have coded it as below. ‘pUnkOuter’ and ‘fullAssemblyPath’ are inputs to the method where the code below is (this code is in a .net assembly which is called from C++ code). The problem is the caller of this method in C++ is not able to QI on the returned ‘innerUnknown’. The QI is not able to get the interfaces that the .NET object implements. Intellisense in C++ show the returned object as RCW object. So how to setup the code below so that C++ code gets the inner unknown and the QI on that succeeds?
var assembly = Assembly.LoadFrom(fullAssemblyPath);
Type typeToLoad = assembly.GetType(className.ToString());
object netObject = typeToLoad.GetConstructor(new Type[] {
}).Invoke(new object[] { });
IntPtr innerUnknown = Marshal.CreateAggregatedObject(Marshal.GetIUnknownForObject(pUnkOuter), netObject);
return innerUnknown;
Raj Peringoth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.