Marshal::GetDelegateForFunctionPointer<TDelegate> Method (IntPtr)
[Supported in the .NET Framework 4.5.1 only]
Converts an unmanaged function pointer to a delegate of a specified type.
Assembly: mscorlib (in mscorlib.dll)
public: generic<typename TDelegate> static TDelegate GetDelegateForFunctionPointer( IntPtr ptr )
The type of the delegate to return.
- Type: System::IntPtr
The unmanaged function pointer to convert.
A instance of the specified delegate type.
You can use the and GetFunctionPointerForDelegate<TDelegate>(TDelegate) methods to marshal delegates in both directions.
The method has the following restrictions:
You cannot pass an invalid function pointer to this method.
You can use this method only for pure unmanaged function pointers.
You cannot use this method with function pointers obtained through C++ or from the GetFunctionPointer method.
You cannot use this method to create a delegate from a function pointer to another managed delegate.
This API is supported in the .NET Framework 4.5.1, but not in version 4.5.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.