views:

27

answers:

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!!

+2  A: 

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

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

Dave McClelland
Thanks Dave. Your answer is a clean shot.
smwikipedia
@smwikipedia Great, glad to hear you were able to get it all sorted out.
Dave McClelland
+2  A: 

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
Thanks Mark. I appreciate your answer.
smwikipedia