|
-
October 22nd, 2002, 08:24 AM
#1
Marshal array of own type
Hello All,
I have a problem using the Marshal class:
I wanna marshaling my class which includes an array of my own type (class), but Marshal.Sizeof always throws an exception (ArgumentException).
Does anyone know what kind of MarshalAs attribute has to be set?
I have tried LPArray, SafeArray and BValArray, no success.
The code looks so:
[StructLayout(LayoutKind.Sequential)]
public class BEntry
{
public UInt32 data1;
public UInt32 data2;
public BEntry( UInt32 d1, UInt32 d2)
{
this.ulData1 = d1;
this.ulData2 = d2;
}
} // class BEntry;
[StructLayout(LayoutKind.Sequential)]
public class BData
{
public UInt16 numberOfEntry;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public BoxEntry[] entries;
public BoxData (UInt16 cEntry, BoxEntry[] entry)
{
this.numberOfEntry = cEntry;
this.entries = new BoxEntry[10];
for (int i = 0; i<10; i++)
this.entries[i] = entry[i];
}
} // class BData
Thanks in advance
Monika
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|