locked
Issue with Jagged-array as State member RRS feed

  • Question

  • Hi all,

     

    In an attempt to use "byte[][] leftBytes" as a state member of my service, I ran into a few errors that I could not understand.

    Please note that I'm still in the process of learning so if I did something terribly wrong, please point it out. Thanks in advance, guys

    Ok, I was doing this:

     

    Code Snippet

    private byte[][] byteLeft;

    [DataMember]

    public byte[][] ByteLeft

    {

    get { return byteLeft; }

    set { byteLeft = value; }

    }

     

     

    And it already gave me the error below, I havent even initialize it.

    Thanks for you help,

    Code Snippet

    Error      1              Cannot convert type 'byte' to 'System.ICloneable'            C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           1281       101                RobotSimulation23

    Error      2              Cannot convert type 'byte' to 'System.ICloneable'            C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           1289       103                RobotSimulation23

    Error      3              Cannot convert type 'byte' to 'System.ICloneable'            C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           1778       96                RobotSimulation23

    Error      4              Cannot convert type 'byte' to 'System.ICloneable'            C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           1786       98                RobotSimulation23

    Error      5              'byte' does not contain a definition for 'Length'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           2360       56                RobotSimulation23

    Error      6              'byte' does not contain a definition for 'Length'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           2386       57                RobotSimulation23

    Error      7              Cannot implicitly convert type 'byte[]' to 'byte'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           3644       40                RobotSimulation23

    Error      8              Cannot implicitly convert type 'byte[]' to 'byte'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Robotics.RobotSimulation23.Proxy.RobotSimulation23Types.cs           3667       41                RobotSimulation23

    Error      9              Invalid rank specifier: expected ',' or ']'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      10           Array creation must have array size or array initializer     C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      11           Invalid rank specifier: expected ',' or ']'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      12           Array creation must have array size or array initializer     C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      13           Invalid rank specifier: expected ',' or ']'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      14           Array creation must have array size or array initializer     C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      15           Invalid rank specifier: expected ',' or ']'  C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      16           Array creation must have array size or array initializer     C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\EXEC                RobotSimulation23

    Error      17           The command ""C:\Microsoft Robotics Studio (1.5)\bin\dssproxy.exe" /dll:"C:\Microsoft Robotics Studio (1.5)\bin\RobotSimulation23.Y2007.M08.dll" /proxyprojectpath:"C:\Microsoft Robotics Studio (1.5)\samples\RobotSimulation23\Proxy " /keyfile:"C:\Microsoft Robotics Studio (1.5)\samples\mrisamples.snk"   /binpath:". " /referencepath:"C:\Microsoft Robotics Studio (1.5)\bin\ " /referencepath:"C:\Microsoft Robotics Studio (1.5)\bin\ "" exited with code 20.             RobotSimulation23

     

     

    Friday, August 31, 2007 2:26 PM

Answers

  • Sorry, we can't support this right now.  We rely on the XmlSerializer, which does not support jagged arrays, or in fact, an array of any enumerable type. 

     

    There is a workaround.  You can create a class which contains the inner array, then create an array of the new class.  Sorry for the hassles.

     

    Also, It looks like you are viewing the error list window.  However, if you look at the output window in Visual Studio, you should see a more descriptive message... something like this:

     

    Code Snippet

    Reflecting: blah.Y2007.M08.dll

    Proxy Path: C:/Mri/Main/Builds/x86dbg/Raw/Private/blah.Y2007.M08/

    *** Error: Invalid [DataMember] field.

    Field: Robotics.Blah.BlahState.Foo

    Type: System.Int32[]

    Reason: Arrays of enumerable types are not supported by the Xml Serializer

     

     

    Dave Lee
    Friday, August 31, 2007 3:54 PM

All replies

  • Sorry, we can't support this right now.  We rely on the XmlSerializer, which does not support jagged arrays, or in fact, an array of any enumerable type. 

     

    There is a workaround.  You can create a class which contains the inner array, then create an array of the new class.  Sorry for the hassles.

     

    Also, It looks like you are viewing the error list window.  However, if you look at the output window in Visual Studio, you should see a more descriptive message... something like this:

     

    Code Snippet

    Reflecting: blah.Y2007.M08.dll

    Proxy Path: C:/Mri/Main/Builds/x86dbg/Raw/Private/blah.Y2007.M08/

    *** Error: Invalid [DataMember] field.

    Field: Robotics.Blah.BlahState.Foo

    Type: System.Int32[]

    Reason: Arrays of enumerable types are not supported by the Xml Serializer

     

     

    Dave Lee
    Friday, August 31, 2007 3:54 PM
  • Thanks, Dave Lee, for your answer,

    I'll check out the workaround you suggested.
    Friday, August 31, 2007 3:57 PM