hi,
the following marshaling code gives me an errror of "type packet cannot be marshaled as an unmanaged structure; no meaningful size or offset can be managed".
public static byte[] StructureToByte sArray(object obj)
{
int len = Marshal.SizeOf( obj);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHG lobal(len);
Marshal.Structu reToPtr(obj, ptr, true);
Marshal.Copy(pt r, arr, 0, len);
Marshal.FreeHGl obal(ptr);
return arr;
}
.
.
.
.
.
this is the structure i am trying to marshal an send thru the socket:
public struct packet
{
public string data;
public string D;
public string SD;
public string PD1;
public string SPD1;
public int[] SBD1;
public int[,] SBD2;
}
.
.
.
byte[] str = StructureToByte sArray(pkt[j]);
i am getting an error for the Marshal.SizeOf( object structure).kind ly help...
thanks in advance
the following marshaling code gives me an errror of "type packet cannot be marshaled as an unmanaged structure; no meaningful size or offset can be managed".
public static byte[] StructureToByte sArray(object obj)
{
int len = Marshal.SizeOf( obj);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHG lobal(len);
Marshal.Structu reToPtr(obj, ptr, true);
Marshal.Copy(pt r, arr, 0, len);
Marshal.FreeHGl obal(ptr);
return arr;
}
.
.
.
.
.
this is the structure i am trying to marshal an send thru the socket:
public struct packet
{
public string data;
public string D;
public string SD;
public string PD1;
public string SPD1;
public int[] SBD1;
public int[,] SBD2;
}
.
.
.
byte[] str = StructureToByte sArray(pkt[j]);
i am getting an error for the Marshal.SizeOf( object structure).kind ly help...
thanks in advance