|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Wrapping Delegates and Unmanaged Function Pointers
The .NET Framework version 2.0 and later provides the ability to marshal function pointers between managed and unmanaged code using the following methods:
Use themethod to marshal an unmanaged function pointer into a delegate. This method uses the class to represent an unmanaged function pointer.
Use themethod to marshal a delegate into a function pointer that is callable from unmanaged code. When you use this method, you must manually keep the delegate from being collected by the garbage collector. The garbage collector does not track references to unmanaged code.
Note that the parameter marshaler can also marshal function pointers to delegates in the .NET Framework 2.0 and later.