Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
john harkin - 21 Sep 2004 08:57 GMT
Hi,
I get this on server when trying to retun a 2 dim array.
I apprecaite that they are not supported as per
http://support.microsoft.com/default.aspx?scid=kb;en-us;316273

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] - 21 Sep 2004 13:53 GMT
You can return jagged arrays, i.e.

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

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

> -----Original Message-----
> From: john harkin [mailto:jjhnospam@yahoo.co.uk]
[quoted text clipped - 17 lines]
>
> JOhn
john harkin - 23 Sep 2004 12:18 GMT
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
 

> You can return jagged arrays, i.e.
>
[quoted text clipped - 28 lines]
>
> --
Christoph Schittko [MVP] - 29 Sep 2004 04:25 GMT
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
http://weblogs.asp.net/cschittko

> -----Original Message-----
> From: john harkin [mailto:jjhnospam@yahoo.co.uk]
[quoted text clipped - 72 lines]
> >
> > --

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.