How to marshal a dynamic sized array

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

    How to marshal a dynamic sized array

    Hi All,

    This is a problem which is eating my head from several days.

    I have a structure which contains an array of elements as


    public byte[] pinNumbers;


    To use it in my C# class i need to marshall it as

    [MarshalAs(Unman agedType.ByValA rray, ArraySubType = UnmanagedType.U 1, SizeConst = 6)]
    public byte[] pinNumbers
    ;

    But here using this marshalling technique , I was forced to pass a fixed size for the array as SizeConst = 6,
    but now i have several arrays which are dynamic arrays whose sizeconst has to be determined at the runtime.

    How can i Marshal dynamic arrays using any marshalling technique ?

    please provide me with a solution as i have tried a lot to marshal arrays using other marshalling styles as well.

    Thanks
    Eric Haas
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Can't you use a constant variable in SizeConst = aContantVariabl e?
    P.S By dynamic array you mean ArrayList?

    Comment

    • Charming12
      New Member
      • Sep 2008
      • 18

      #3
      Thanks for replying

      yes by dynamic array i mean varaible length array whose size can not be fixed it has to be passed at run time.

      passing a const size is not what is required in the program.

      Comment

      • aaronwilke1978
        New Member
        • Feb 2014
        • 1

        #4
        Did you ever find a solution for this? I'm trying to do the same thing.

        Comment

        Working...