System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate Method

Converts a delegate into a function pointer that is callable from unmanaged code.

Syntax

public static IntPtr GetFunctionPointerForDelegate (Delegate d)

Parameters

d
The delegate to be passed to unmanaged code.

Returns

A value that can be passed to unmanaged code, which, in turn, can use it to call the underlying managed delegate.

Remarks

The delegate d is converted to a function pointer that can be passed to unmanaged code using the __stdcall calling convention.

You must manually keep the delegate from being collected by the garbage collector from managed code. The garbage collector does not track references to unmanaged code.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0