public static IntPtr /* IUnknown* */ GetComInterfaceForObject(Object o, Type t) { if (o == null) { throw new ArgumentNullException("o"); } if (t == null) { throw new ArgumentNullException("type"); } RuntimeTypeHandle interfaceTypeHandle = t.TypeHandle; McgTypeInfo secondTypeInfo; McgTypeInfo mcgTypeInfo = McgModuleManager.GetTypeInfoFromTypeHandle(interfaceTypeHandle, out secondTypeInfo); if (mcgTypeInfo.IsNull) { #if CORECLR return(default(IntPtr)); #else throw new MissingInteropDataException(SR.ComTypeMarshalling_MissingInteropData, t); #endif } return(McgMarshal.ObjectToComInterface(o, mcgTypeInfo)); }
internal static unsafe IntPtr ManagedObjectToComInterface(Object obj, RuntimeTypeHandle typeHandle) { McgTypeInfo secondTypeInfo; return(ManagedObjectToComInterface(obj, McgModuleManager.GetTypeInfoFromTypeHandle(typeHandle, out secondTypeInfo))); }