marshal to a Variable length Array RRS feed

  • Question

  •  Hi ,

    I am getting  data from a file in binary format ,  which should be de-serialize to a  a different  Structs .

     Desierilazation is work fine if the struct contain  fixed length array by providing  

     ex: [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)].

    But I have to de-serialize to a struct contain  variable length array whose size is determined based on the pointer .

    The struct is provided here ...

    public struct  DL_BITMAP 

         public int lOrgX;
        public int lOrgY;
        public int lWidth;
        public int lHeight;
        public uint dwFlag;
        public uint rgbPixel;
         public byte[] lPixel;

    Upon de-serializing  the  the public byte[] lPixel  contain only one value .

    Is there any way to  marshal to variable length array .

    How the CustomMarshaller  is implemented

    Monday, July 22, 2019 10:33 AM

All replies