Is there a table of the matching types for marshaling in P/Invoke & InterOP?
I am almost buried by how the different dialects of types are matched between .NET world and native world. Such as MFC CList and other stuffs.
I am desperately hoping for this:
- Some kind of table or cheetsheet that lists all the mappings between types of .NET world and native worl开发者_StackOverflowd.
- A table that lists all the types that can be marshaled.
Great thanks!!
For information on default type conversion, try this chart out.
For information on Marhsaling in general, check this page out.
The UnmanagedType
enum gives a pretty complete list of the target types you want. It covers all the core types available in C atleast. For user defined types in C, you'll need to check if they are typedefs of a standard type, or in the case of structures, you need to rewrite the structure in C# and marshal each field of it manually.
C++ classes (such as MFC) aren't covered here. P/Invoke does not support the __thiscall
calling convention (ie, class methods). The common scenarios on importing C++ code to C# are to write a COM wrapper for the class using C++/CLI, or to write a C based wrapper from C++ (mark code extern "C"), and then use P/Invoke on the wrapper.
精彩评论