Tried that, GCHandle.Alloc() throws an exception about non-blittable memory.

Rossj wrote:
PhrostByte wrote:
in memory.


GCHandle.Alloc( myDelegate, GCHandleType.Pinned ) ?

As in

GCHandle handle = GCHandle.Allow( d, GCHandleType.Pinned );
setdelegate(d); // p/invoked, stores the function pointer
somefunc() // p/invoked, can call function pointer.
handle.Free();

Edit: Free is not static, and should only be called once.