error about"cannot be marshaled as an unmanaged structure"

softlife12 2006-04-04 10:56:42
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
...全文
649 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
真相重于对错 2006-04-04
  • 打赏
  • 举报
回复
2005 没有用过错误的意思是你不能封送一个无法定义长度的非托管结构
softlife12 2006-04-04
  • 打赏
  • 举报
回复
2.0也不支持

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧