2

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 world.
  • A table that lists all the types that can be marshaled.

Great thanks!!

smwikipedia
  • 61,609
  • 92
  • 309
  • 482

2 Answers2

2

For information on default type conversion, try this chart out.

For information on Marhsaling in general, check this page out.

Dave McClelland
  • 3,385
  • 1
  • 29
  • 44
2

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.

Mark H
  • 13,797
  • 4
  • 31
  • 45