error about"cannot be marshaled as an unmanaged structure"

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top