C# does not support fixed-length arrays embedded in a struct (except in an unsafe context) so your C structure is probably being marshalled into a C# structure something like this:
struct USERINFO
{
MarshalAs(UnmanagedType.ByValArray, SizeConst = 42)
BYTE[] UserID;
MarshalAs(UnmanagedType.ByValArray, SizeConst = 66)
BYTE[] FirstName;
// etc.
};
Note that the members are references to arrays, not embedded arrays.
For the marshalling to work the arrays have to be exactly the right length (or maybe at least the right length, I forget). For example, UserID should be initialised with userInfo.UserID = new byte[42];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…