protected internal ComObject(IComInterface comInterface) { if (comInterface == null) { throw new ArgumentNullException(nameof(comInterface)); } _comInterface = comInterface; }
public static void TestComInteropNullPointers() { Console.WriteLine("Testing Marshal APIs for COM interfaces"); IComInterface comPointer = null; var result = IsNULL(comPointer); ThrowIfNotEquals(true, IsNULL(comPointer), "COM interface marshalling null check failed"); }
public ImprovedClass() { var typeBaseIComInterface = typeof(OldLibrary.BaseClass).GetInterfaces().First((t) => t.GUID == typeof(IComInterface).GUID); // get OldLibrary.BaseClass.IComInterface this.unkBaseIComInterface = Marshal.GetComInterfaceForObject(this, typeBaseIComInterface, CustomQueryInterfaceMode.Ignore); this.unkBaseShim = Marshal.CreateAggregatedObject(this.unkBaseIComInterface, new Inner(this.unkBaseIComInterface)); this.baseComInterface = (IComInterface)Marshal.GetTypedObjectForIUnknown(this.unkBaseShim, typeof(IComInterface)); ((IComInterface)this).ComMethod(this); // works! }
static extern int BuildComPointer(out IComInterface foo);
static extern int RetrieveCapturedComPointer(out IComInterface foo);
static extern int CaptureComPointer(IComInterface foo);
static extern bool IsNULL(IComInterface foo);
public static extern void GetIComInterfaceCs([MarshalAs(UnmanagedType.Interface)] ref IComInterface <char> pValues, int count);
public static extern void GetIComInterfaceCOut([MarshalAs(UnmanagedType.Interface)] out IComInterface <char> value);
protected internal ComObject(IComInterface comInterface) { if (comInterface == null) throw new ArgumentNullException(nameof(comInterface)); _comInterface = comInterface; }