To become really proficient at good interop code, one must master a range of skills. The MSDN documentation is rather spread out regarding this, so here’s an attempt to bring it together, as a “C++ .NET interop quick reference”:
- Development Tools and Languages :: Visual Studio :: .NET Framework Programming in Visual Studio :: .NET Framework Advanced Development :: Interoperability :: Interoperating with Unmanaged Code :: Interop Marshaling :: Marshaling Data with Platform Invoke - Gives a good overview of how to marshal the actual data to and from unmanaged code. Particularly useful when dealing with arrays and strings.
- Development Tools and Languages :: Visual Studio :: Visual C++ :: .NET Programming Guide :: Interoperability with Other .NET Languages - Details how to get C#-like behavior in C++.
- Development Tools and Languages :: Visual Studio :: Visual C++ :: Reference :: C/C++ Languages :: C++ Language Reference :: Language Features for Targeting the CLR - Reference information for cli::pin_ptr, cli::array, managed enums, etc.
- .NET Development :: .NET Framework SDK :: .NET Framework :: .NET Framework Class Library :: System.Runtime.InteropServices Namespace :: Marshal Class - A BCL type that defines some very useful functions such as PtrToString* and StringTo*.