Bonjour,
J'ai essaie de compiler le code suivant :
mais le compilateur sort avec l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 somedata = new Byte[1024]; unsafe { fixed ( byte *pData = somedata) { MY_STRUCT1* ptr = (MY_STRUCT1*)pData; }
sur la ligne avec l'initialisation du pointer ptr.Error 38 Cannot take the address of, get the size of, or declare a pointer to a managed type MY_STRUCT1 ...
La structure MY_STRUCT1 :
Si la structure ne contient pas la ligne avec le byte-array abParamVal, ca compile.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 [Serializable] [StructLayout(LayoutKind.Sequential, Pack=1)] public struct MY_STRUCT1 { int par1; int par2; [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)] public byte [] abParamVal; }
Est-ce il y a une explication pour ca ?
Merci d'avance.
Abra
Partager