I ont les suivantes struct C++:sérialisation un ensemble de courts métrages: "Mismatch est produite"
typedef struct FormulaSyntax{
WORD StructSize;
short formulaSyntax [2];
} FormulaSyntax;
I ont une méthode DLL qui prend une instance de cette structure. Voici ce que j'ai essayé sur le côté C#:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FormulaSyntax {
public short StructSize;
public short[] formulaSyntax;
}
[DllImport(DLL_NAME, EntryPoint = "PEGetFormulaSyntax",
CharSet = CharSet.Unicode)]
public static extern bool getFormulaSyntax(short reportID,
ref FormulaSyntax syntax);
...
FormulaSyntax syntax = new FormulaSyntax();
syntax.formulaSyntax = new short[2];
syntax.StructSize = (short)Marshal.SizeOf(syntax);
PrintEngine.getFormulaSyntax(context.oldApiID, ref syntax);
Ce plante, me donner le message
Mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata.
Qu'est-ce que je fais mal?