I am doing some C# interop work. I have the following struct:
#pragma pack(push,1)
typedef struct
{
unsigned __int64 Handle;
LinkType_t Type;
Lin
whenever I initialize the struct the Name, DeviceInfo, and Reserved fields are all set to null
This is correct, and your definition looks OK to me (BTW, you don't need [MarshalAs]
on the primitive fields, the default behaviour is to do what you specified there). Because your array fields are null
, the marshaler won't do anything about them when marshaling your struct to unmanaged memory, but it's going to create the strings and arrays when unmarshaling.