Visual Studio.NET 2003 generates type object[] for ArrayList method return

Discussion in 'ASP .Net Web Services' started by JDeats, Oct 27, 2003.

  1. JDeats

    JDeats Guest

    I've noticed what appears to be a bug in the Visual Studio.NET (1.0
    and 2003 versions). If I declare a web method like so:

    [WebMethod]
    public ArrayList GetMyList()
    {
    ArrayList list = new ArrayList()
    list.Add("one");
    list.Add("two");
    return list;
    }


    If I bind to the above from a client application like so:

    ArrayList newlist = mywebservice.GetMyList();

    The above fails (sometimes, sometimes it works), the compiler expects
    a type of object[] (object array) and not ArrayList. Casting also
    fails. I've even tried the following:


    [WebMethod]
    public object[] GetMyList()
    {
    ArrayList list = new ArrayList()
    list.Add("one");
    list.Add("two");
    return list.ToArray();
    }

    Sometimes it works, sometimes it doesn't work. The later example never
    works. Can anyone explain this? Is it a IDE generated code bug?
    JDeats, Oct 27, 2003
    #1
    1. Advertising

  2. have a look at this
    http://www.fawcette.com/vsm/2001_12/online/online_eprods/webservices_yshohoud12_12/default_pf.aspx

    It explains the situation you are confronting.

    -Dino


    "JDeats" <> wrote in message
    news:...
    > I've noticed what appears to be a bug in the Visual Studio.NET (1.0
    > and 2003 versions). If I declare a web method like so:
    >
    > [WebMethod]
    > public ArrayList GetMyList()
    > {
    > ArrayList list = new ArrayList()
    > list.Add("one");
    > list.Add("two");
    > return list;
    > }
    >
    >
    > If I bind to the above from a client application like so:
    >
    > ArrayList newlist = mywebservice.GetMyList();
    >
    > The above fails (sometimes, sometimes it works), the compiler expects
    > a type of object[] (object array) and not ArrayList. Casting also
    > fails. I've even tried the following:
    >
    >
    > [WebMethod]
    > public object[] GetMyList()
    > {
    > ArrayList list = new ArrayList()
    > list.Add("one");
    > list.Add("two");
    > return list.ToArray();
    > }
    >
    > Sometimes it works, sometimes it doesn't work. The later example never
    > works. Can anyone explain this? Is it a IDE generated code bug?
    Dino Chiesa [Microsoft], Oct 31, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh
    Replies:
    2
    Views:
    489
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. rockdale
    Replies:
    1
    Views:
    584
    Juan T. Llibre
    Aug 23, 2006
  3. hunkgym
    Replies:
    1
    Views:
    1,970
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 30, 2006
  4. xman
    Replies:
    0
    Views:
    459
  5. xman
    Replies:
    1
    Views:
    557
    Victor Bazarov
    Aug 17, 2005
Loading...

Share This Page