Esempio n. 1
0
    public static void InRef()
    {
        IntPtr handleValue = new IntPtr(4);

        Native.InRefCallback callback = (ref MyCriticalHandle handle) => { };
        Assert.Throws <MarshalDirectiveException>(() => Native.InvokeInRefCallback(callback, ref handleValue));
        GC.KeepAlive(callback);
    }
    public static void InRef()
    {
        IntPtr handleValue = new IntPtr(4);

        Native.InRefCallback callback = (ref MyCriticalHandle handle) => { };
        Assert.Throws <MarshalDirectiveException>(() => Native.InvokeInRefCallback(callback, ref handleValue), "Calling P/Invoke that invokes a delegate that has an [In] ref CriticalHandle parameter");
        GC.KeepAlive(callback);
    }