Passing an array to StructureToPtr

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Charming12
    New Member
    • Sep 2008
    • 18

    Passing an array to StructureToPtr

    Hi All,
    Got stuck with a problem for which i am unable to think of workaround.

    I got an structure which contains an array of another structure.

    i.e,

    structure abc
    {
    public int code;
    }

    structure xyz
    {
    public abc[] structobj;
    }

    xyz obj = new xyz();
    obj.structobj[0].code = 2;

    while using StructureToPtr

    int size = Marshal.SizeOf( obj);
    IntPtr data = Marshal.AllocHG lobal(size);
    Marshal.Structu reToPtr(obj, data, true);


    at this step it is showing an error as Incorrect parameters.
    However if i am not using an array of structure it is working fine.

    Please suggest what should be done.

    Thanks
    Eric Haas
Working...