i am using a COM dll in my C# Project.
I have one USERINFO Structure in my COM dll which looks like :
struct USERINFO
{
BYTE UserID[USER_ID_SIZE];//42
BYTE FirstName[NAME_SIZE];//66
BYTE LastName[NAME_SIZE]; //66
long Pin;
BYTE TimeGroupIDList[IDLIST_SIZE];//10
enum EUserKind eUserKind;
BYTE WarningEye;
};
When i use this structure in my C# Application to fill this structure for User data and pass to my AddUser API it returns this Error.
Any help is appreciated.
Thanks.
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:
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];