I'm currently working on some C# code that calls into a custom, native dll. When marshaling data back to C#, I have need to explicitly align the fields of the classes/structs used for marshaling. I've had a number of issues with this stemming from an incomplete understanding of the marshaler and its rules. For example, I recently found out through a SO question that the marshaler requires arrays to be DWORD aligned. Had I known this earlier, it would have saved me some headache.
My question is two-fold:
1) Is there any good documentation for the marshaler that provides this type of information?
2) What other similar restrictions should I be aware of? (For example, do all DWORD-sized fields have to be DWORD aligned)?