Bonjour à tous,

Dans mon programme, je dois créer un objet puis le transmettre vers un équipement pour impression.
Le problème arrive quand je souhaite créer cet objet en question. j'obtiens le message suivant :

Une exception non gérée du type 'System.TypeLoadException' s'est produite dans System.Windows.Forms.dll

Informations supplémentaires*: Impossible de charger le type 'PrintBuildObject', car il contient un champ objet à l'offset '9' qui n'est pas correctement aligné ou qui est chevauché par un champ non objet.
Exemple du code définissant l'objet capricieux :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
public enum IMS_eGraphicObject
{
    OBJECT_TEXT=0,
    OBJECT_LINE=1,
    OBJECT_BOX=2,
    OBJECT_LOGO=3,
    OBJECT_MAG=4,
    OBJECT_SERIAL=5,
    OBJECT_CLESS=6,
}
 
[StructLayout(LayoutKind.Sequential)]
public class FormatGraphic
{
    public byte objectType;
    public UInt16 X;
    public UInt16 Y;
    public IMS_eGraphicObject objectId;
}
 
[StructLayout(LayoutKind.Explicit)]
public class PrintBuildObject
{
    [FieldOffset(0)]
    public FormatGraphic Format;
    [FieldOffset(9)]
    public PrintBuildDataText PrintBuildDataText;
    [FieldOffset(9)]
    public PrintBuildDataLine PrintBuildDataLine;
    [FieldOffset(9)]
    public PrintBuildDataBox PrintBuildDataBox;
    [FieldOffset(9)]
    public PrintBuildDataLogo PrintBuildDataLogo;
    [FieldOffset(9)]
    public EncodeBuildDataMag EncodeBuildDataMag;
}
Merci d'avance pour vos lumières.