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. Advertisements

  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. Advertisements

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. Bootstrap Bill

    Visual Studio .net 2003 and Frotpage 2003

    Bootstrap Bill, Sep 12, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    783
    Bootstrap Bill
    Sep 17, 2004
  2. Kieran Kelly
    Replies:
    3
    Views:
    1,077
    Shaji
    Sep 29, 2003
  3. wh
    Replies:
    2
    Views:
    879
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  4. Stewart
    Replies:
    1
    Views:
    709
    Ken Cox [Microsoft MVP]
    Feb 24, 2006
  5. rockdale
    Replies:
    1
    Views:
    955
    Juan T. Llibre
    Aug 23, 2006
  6. hunkgym
    Replies:
    1
    Views:
    2,279
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 30, 2006
  7. xman
    Replies:
    1
    Views:
    923
    Victor Bazarov
    Aug 17, 2005
  8. KevinGPO
    Replies:
    1
    Views:
    457
    Victor Bazarov
    Mar 6, 2006
Loading...