Hi, again!
How can I make a new structure, which contains others structures?
I have two structures, which contains only native types (byte, uint) and I have a need for a new structure, which contains these my own datatypes (structures).
When I use Marshal.SizeOf(struct_object), I get the sizes of the structures, 10 and 20 bytes
Now, when I make a new structure:
If I call Marshal.SizeOf(param_def_object) -method, I get an error:Converter.Param_def can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
What's wrong in my Param_def -structure?
br. Juha Ka
How can I make a new structure, which contains others structures?
I have two structures, which contains only native types (byte, uint) and I have a need for a new structure, which contains these my own datatypes (structures).
Code:
[ StructLayout( LayoutKind.Sequential )]
public struct MSettings_def
{
public byte MFormat;
[MarshalAs( UnmanagedType.ByValArray, SizeConst=4)]
public byte[] MObjects;
[MarshalAs( UnmanagedType.ByValArray, SizeConst=4)]
public byte[] ONumber;
public byte Brightness;
}
[ StructLayout( LayoutKind.Sequential )]
public struct Rparam_def
{
public byte UpperPoint;
public byte LowerPoint;
public byte MaxSpeed;
public byte MinSpeed;
[MarshalAs( UnmanagedType.ByValArray, SizeConst=4)]
public uint[] Valves;
}
When I use Marshal.SizeOf(struct_object), I get the sizes of the structures, 10 and 20 bytes
Now, when I make a new structure:
Code:
public struct Param_def
{
[MarshalAs( UnmanagedType.ByValArray, SizeConst=10)]
byte[] Name;
[MarshalAs( UnmanagedType.ByValArray, SizeConst=80)]
byte[] Comment;
MSettings_def msf;
[MarshalAs( UnmanagedType.ByValArray, SizeConst=10)]
Rparam_def[] rpd;
}
If I call Marshal.SizeOf(param_def_object) -method, I get an error:Converter.Param_def can not be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
What's wrong in my Param_def -structure?
br. Juha Ka