error about"cannot be marshaled as an unmanaged structure"

  • Thread starter Thread starter shengmin.ruan
  • Start date Start date
S

shengmin.ruan

i got a struct like:
---------------------
public ref struct OutPacket{
int m_replyIndex;
List<MainInfo^>^ m_mainInfos;
};
---------------------


when i pass it to another process, i have to transfer it to intptr :
---------------------
IntPtr pnt = Marshal::AllocCoTaskMem(Marshal::SizeOf(outPacket));
Marshal::StructureToPtr(outPacket,pnt,true);
return pnt;
---------------------

then i got a message:

*********
err = {"Type 'CProcess.OutPacket' cannot be marshaled as an unmanaged
structure; no meaningful size or offset can be computed."}
*********

i think the trouble is that i have to process a "List<>"Type,maybe i
should use "StructLayout",but i can't handle this well,
please help me thank u
 
Back
Top