public static void Ref() { IntPtr handleValue = new IntPtr(5); Native.RefCallback callback = (ref MyCriticalHandle handle) => { }; Assert.Throws <MarshalDirectiveException>(() => Native.InvokeRefCallback(callback, ref handleValue)); GC.KeepAlive(callback); }
public static void Ref() { IntPtr handleValue = new IntPtr(5); Native.RefCallback callback = (ref MyCriticalHandle handle) => { }; Assert.Throws <MarshalDirectiveException>(() => Native.InvokeRefCallback(callback, ref handleValue), "Calling P/Invoke that invokes a delegate that has an ref CriticalHandle parameter"); GC.KeepAlive(callback); }