.NET supports interoperability with APIs in native DLLs as well as with COM components. The SDK defines a collection of classes under the namespace System.Runtime.InteropServices to support this interoperability.
The ability to access APIs in native DLLs is offered through a mechanism called PInvoke, which offers a great deal of support for marshaling basic datatypes, pointers, and even structures.
The default marshaling options used by the interop marshaler try to make interoperability as seamless as possible. In cases where there is an ambiguity on how a managed type can be marshaled, the .NET Framework defines a mechanism to let the developers provide marshaling hints to the interop marshaler.
The framework also defines a mechanism ...