How to parse struct to C++ dll from C#? -
I am trying to call the function in an unmanaged C ++ dll.
This is the prototype:
[DllImport ("C: \\ Program Files \\ MySDK \\ VSeries.dll", EntryPoint = "BII_Send_Index_Template_MT"]] Internal Unprotected Fixed extern Int32 BII_Send_Index_Template_MT (IntPtr pUnitHandle, Ref BII_Template Template, Int32 Option, Boolean async); BII_Template Template = New BII_Template (); Error_code = BII_Send_Index_Template_MT (pUnitHandle, Ref Template, Options, Incorrect);
< P> In this way I use BII_Template struct as C #: Public Unsafe Structure BII_Template {public ulong id; Public emerging employee_id; public inversion password; universal Public byte sensor_varjan; public byte template_varjan; public fixed letter [16]; public byte finger; public byte admin_level; public byte schedule; public byte protection_documentation; public fixed byte noise_level [18]; public byte corrumb; public byte context_x; public byte reference_y ; Public fixed byte Ihkoor [3]; public fixed byte ivcore [3]; public byte temp_xoffset; Public byte temp_yoffset; Public byte index; Public fixed byte infection [5500]; };
It builds and when I run it dll return_code = "record checksum is invalid."
I think I have incorrectly or the size of some elements in the structure is wrong
----- Edit ---- --------
Here is the straight in C ++:
typedef Struct {unsigned long ID; Unsigned long employee_id; Unsigned long password; Unsigned char sensor_version; Unsigned four template_version; Four names [16]; Unsigned four finger; Unsigned four administrators_level; Unsigned four events; Unsigned four security_yes; Unsigned four noise levels [18]; Unsigned four confusion; Unsigned cell reference_x; Unsigned four reference_as; Unsigned four eyebrows [NUM_CORE]; Unsigned four ivcore [NUM_CORE]; Unsigned four temp_xoffset; Unsigned four temp_yoffset; Unsigned char index; Unsigned four inputs [PACKED_ARRAY_SIZE]; } BII_Template;
After a lot of testing it is decided that the fixed four ... Does not use such [torch ...] after making this change it worked. public structure BII_Template {public UIT ID; Public UIT staff_ID; Public UIT password; };
public byte sensor_version; Public byte template_version; [Marshall (UnmanagedType.ByValArray, SizeConst = 16)] Public byte [] name; Public byte finger; Public byte admin_level; Public byte schedule; Public byte protection_drug; [Marshall (UnmanagedType.ByValArray, SizeConst = 18)] Public Byte [] noise_level; Public byte corram; Public byte reference_x; Public byte reference_a; [Marshall (UnmanagedType.ByValArray, SizeConst = 3)] Public Byte [] ihcore; [Marshall (UnmanagedType.ByValArray, SizeConst = 3)] Public Byte [] ivcore; Public byte temp_xoffset; Public byte temp_yoffset; Public byte index; [Marshall AS (unmanaged type. Bevalererere, size consort = 5500)] Public byte [] Infections;
Comments
Post a Comment