Unable to cast object of type 'System.Byte[*]' to type 'System.Byte[]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • miller.brettm@gmail.com

    Unable to cast object of type 'System.Byte[*]' to type 'System.Byte[]


    Hi,

    I'm working with an ActiveX serial component that fires an event when
    data is received. I need to continue to use this component because it
    contains the ability to do Xmodem1k an d XmodemCRC comms

    The RX even fires and passes an Object (Type: Object) parameter. When
    looking @ the Locals window it shows the Type as: Object { byte[] }

    <Code>
    Byte[] b = (Byte[])e.Data; //(Type Object)
    </Code>

    System.InvalidC astException: Unable to cast object of type
    'System.Byte[*]' to type 'System.Byte[]

    I've never seen a System.Byte[*] with an Asterrix before... Google
    returns nothing....

    Thanks for any help!
    Bm
  • Ben Voigt [C++ MVP]

    #2
    Re: Unable to cast object of type 'System.Byte[*]' to type 'System.Byte[]

    miller.brettm@g mail.com wrote:
    Hi,
    >
    I'm working with an ActiveX serial component that fires an event when
    data is received. I need to continue to use this component because it
    contains the ability to do Xmodem1k an d XmodemCRC comms
    >
    The RX even fires and passes an Object (Type: Object) parameter. When
    looking @ the Locals window it shows the Type as: Object { byte[] }
    >
    <Code>
    Byte[] b = (Byte[])e.Data; //(Type Object)
    </Code>
    >
    System.InvalidC astException: Unable to cast object of type
    'System.Byte[*]' to type 'System.Byte[]
    >
    I've never seen a System.Byte[*] with an Asterrix before... Google
    returns nothing....
    >
    Thanks for any help!
    I'd suggest casting to System.Array (or just using the watch window) and
    checking the rank, maybe it's not rank 1.
    Bm

    Comment

    Working...