Cannot serialize object of type System.Object[,]. Multidimensional arrays are not supported

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Cannot serialize object of type System.Object[,]. Multidimensional arrays are not supported

    Hi,
    I get this on server when trying to retun a 2 dim array.
    I apprecaite that they are not supported as per
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;316273[/url]

    however i'm looking for as a work around as my web service is a layer
    in front of an existing com object which cannot be changed and it
    returns the 2 dim array.

    All thoughts welcome.

    JOhn
    john harkin Guest

  2. Similar Questions and Discussions

    1. Object of type 'System.String' cannot be converted to type 'System
      I'm trying to get a control from metabuilders.com dual list)to work under ASP.NET 2.0. It worked find under 1.1 and then when i migrated my...
    2. [WebMethod] System.NullReferenceException: Object reference not set to an instance of an object.
      Um, this isn't going to work, generally. Web services, as any web app (especially on Windows server 2003) are heavily sandboxed. The method you...
    3. Split multidimensional array into 4 multidimensional arrays
      Hello everyone, I have a multidimensional array that I need to split into 4 multidimensional arrays. I've tried the examples from the...
    4. Cannot serialize the object using XmlSerializer
      I have a feeling I'm missing something simple here. I cannot get even the most simple WebControl to be serialized into an XML file. I keep getting...
    5. Cannot create an object of type 'System.String[]' from its representation 'String[] Array'
      Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To...
  3. #2

    Default Re: Cannot serialize object of type System.Object[,]. Multidimensional arrays are not supported

    You can return jagged arrays, i.e.

    System.Object[][] instead of System.Object[,].

    HTH,
    Christoph Schittko
    MVP XML
    [url]http://weblogs.asp.net/cschittko[/url]
    > -----Original Message-----
    > From: john harkin [mailto:jjhnospam@yahoo.co.uk]
    > Posted At: Tuesday, September 21, 2004 2:58 AM
    > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
    > Conversation: Cannot serialize object of type System.Object[,].
    > Multidimensional arrays are not supported
    > Subject: Cannot serialize object of type System.Object[,].
    > Multidimensional arrays are not supported
    >
    > Hi,
    > I get this on server when trying to retun a 2 dim array.
    > I apprecaite that they are not supported as per
    > [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;316273[/url]
    >
    > however i'm looking for as a work around as my web service is a layer
    > in front of an existing com object which cannot be changed and it
    > returns the 2 dim array.
    >
    > All thoughts welcome.
    >
    > JOhn
    Christoph Schittko [MVP] Guest

  4. #3

    Default Re: Cannot serialize object of type System.Object[,]. Multidimensional arrays are not supported

    Hi,
    Thanks very much for this and it worked.
    I'm actually need to retun an object which could contain object[][].
    One thing i notice


    [WebMethod]
    public object ReturnJaggedArrayAsObject()
    {
    object[][] numbers = new object[2][] { new object[] {2,"string1",
    24.56}, new object[] {4,"string2", 56.78} };
    object a = (object) numbers;
    return a;

    }

    didn't work and got a serialisation error but when i added

    [WebMethod]
    public object[][] Fred()
    {
    object[][] numbers = new object[2][] { new object[] {2,"string1",
    24.56}, new object[] {4,"string2", 56.78} };

    return numbers;

    }

    to the source file i was able to call ReturnJaggedArrayAsObject.
    It appears that by having Fred it knows about object[][] in wsdl.
    Any way of achieving this without defining Fred?

    Regards


    "Christoph Schittko [MVP]" <INVALIDEMAIL@austin.rr.com> wrote in message news:<#$za3n9nEHA.2616@tk2msftngp13.phx.gbl>...
    > You can return jagged arrays, i.e.
    >
    > System.Object[][] instead of System.Object[,].
    >
    > HTH,
    > Christoph Schittko
    > MVP XML
    > [url]http://weblogs.asp.net/cschittko[/url]
    >
    > > -----Original Message-----
    > > From: john harkin [mailto:jjhnospam@yahoo.co.uk]
    > > Posted At: Tuesday, September 21, 2004 2:58 AM
    > > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
    > > Conversation: Cannot serialize object of type System.Object[,].
    > > Multidimensional arrays are not supported
    > > Subject: Cannot serialize object of type System.Object[,].
    > > Multidimensional arrays are not supported
    > >
    > > Hi,
    > > I get this on server when trying to retun a 2 dim array.
    > > I apprecaite that they are not supported as per
    > > [url]http://support.microsoft.com/default.aspx?scidkb;en-us;316273[/url]
    > >
    > > however i'm looking for as a work around as my web service is a layer
    > > in front of an existing com object which cannot be changed and it
    > > returns the 2 dim array.
    > >
    > > All thoughts welcome.
    > >
    > > JOhn
    >
    > --
    john harkin Guest

  5. #4

    Default Re: Cannot serialize object of type System.Object[,]. Multidimensional arrays are not supported

    Have you tried declaring the array via an Xml serialization attribute on
    the return value:

    [WebMethod]
    [return: XmlElement(typeof(object[][]))]
    public object ReturnJaggedArrayAsObject()
    {
    object[][] numbers = new object[2][]
    {
    new object[] {2,"string1", 24.56}, new object[]
    {4,"string2", 56.78} };


    You may have to attach more attributes to declare the types in the
    array... not sure at all if this works.

    HTH
    Christoph Schittko
    MVP XML
    [url]http://weblogs.asp.net/cschittko[/url]
    > -----Original Message-----
    > From: john harkin [mailto:jjhnospam@yahoo.co.uk]
    > Posted At: Thursday, September 23, 2004 6:18 AM
    > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
    > Conversation: Cannot serialize object of type System.Object[,].
    > Multidimensional arrays are not supported
    > Subject: Re: Cannot serialize object of type System.Object[,].
    > Multidimensional arrays are not supported
    >
    > Hi,
    > Thanks very much for this and it worked.
    > I'm actually need to retun an object which could contain object[][].
    > One thing i notice
    >
    >
    > [WebMethod]
    > public object ReturnJaggedArrayAsObject()
    > {
    > object[][] numbers = new object[2][] { new
    object[]
    > {2,"string1",
    > 24.56}, new object[] {4,"string2", 56.78} };
    > object a = (object) numbers;
    > return a;
    >
    > }
    >
    > didn't work and got a serialisation error but when i added
    >
    > [WebMethod]
    > public object[][] Fred()
    > {
    > object[][] numbers = new object[2][] { new
    object[]
    > {2,"string1",
    > 24.56}, new object[] {4,"string2", 56.78} };
    >
    > return numbers;
    >
    > }
    >
    > to the source file i was able to call ReturnJaggedArrayAsObject.
    > It appears that by having Fred it knows about object[][] in wsdl.
    > Any way of achieving this without defining Fred?
    >
    > Regards
    >
    >
    > "Christoph Schittko [MVP]" <INVALIDEMAIL@austin.rr.com> wrote in
    message
    > news:<#$za3n9nEHA.2616@tk2msftngp13.phx.gbl>...
    > > You can return jagged arrays, i.e.
    > >
    > > System.Object[][] instead of System.Object[,].
    > >
    > > HTH,
    > > Christoph Schittko
    > > MVP XML
    > > [url]http://weblogs.asp.net/cschittko[/url]
    > >
    > > > -----Original Message-----
    > > > From: john harkin [mailto:jjhnospam@yahoo.co.uk]
    > > > Posted At: Tuesday, September 21, 2004 2:58 AM
    > > > Posted To: microsoft.public.dotnet.framework.aspnet.webservic es
    > > > Conversation: Cannot serialize object of type System.Object[,].
    > > > Multidimensional arrays are not supported
    > > > Subject: Cannot serialize object of type System.Object[,].
    > > > Multidimensional arrays are not supported
    > > >
    > > > Hi,
    > > > I get this on server when trying to retun a 2 dim array.
    > > > I apprecaite that they are not supported as per
    > > > [url]http://support.microsoft.com/default.aspx?scidkb;en-us;316273[/url]
    > > >
    > > > however i'm looking for as a work around as my web service is a
    layer
    > > > in front of an existing com object which cannot be changed and it
    > > > returns the 2 dim array.
    > > >
    > > > All thoughts welcome.
    > > >
    > > > JOhn
    > >
    > > --
    Christoph Schittko [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139