C
Cyril
Hello,
I have a problem to marshal a structure that contains an array of an
others struct. This array is an array size fixed (MyStruct[2] myStructs
and not MyStruct *myStructs).
For example :
C declaration :
struct Point {
int x;
int y;
}
struct Line {
Point[2] points;
int id;
}
For the C# declaration, I have try this declaration but this don't work
:
[StructLayout(LayoutKind.Explicit)]
public struct Point
{
[FieldOffset(0)] public int x;
[FieldOffset(4)] public int y;
}
[StructLayout(LayoutKind.Explicit)]
public struct Line
{
[FieldOffset(0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Point[] points;
[FieldOffset(8)] public int id;
}
I have try other declaration but I haven't find solution.
If you have solution or some councils please tell me.
Thanks,
Cyril
PS : You can send the VB.Net solution too...
I have a problem to marshal a structure that contains an array of an
others struct. This array is an array size fixed (MyStruct[2] myStructs
and not MyStruct *myStructs).
For example :
C declaration :
struct Point {
int x;
int y;
}
struct Line {
Point[2] points;
int id;
}
For the C# declaration, I have try this declaration but this don't work
:
[StructLayout(LayoutKind.Explicit)]
public struct Point
{
[FieldOffset(0)] public int x;
[FieldOffset(4)] public int y;
}
[StructLayout(LayoutKind.Explicit)]
public struct Line
{
[FieldOffset(0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
public Point[] points;
[FieldOffset(8)] public int id;
}
I have try other declaration but I haven't find solution.
If you have solution or some councils please tell me.
Thanks,
Cyril
PS : You can send the VB.Net solution too...