Custom object with a System.Web.Security.MembershipUserCollection property - "implement a default ac

Discussion in 'ASP .Net Web Services' started by justin.drerup@gmail.com, May 20, 2006.

  1. Guest

    I'm tryng to return a custom object that contains a collection of
    MembershipUsers through a web service however I receive the following
    error when trying to return the object through a web method:

    You must implement a default accessor on
    System.Web.Security.MembershipUserCollection because it inherits from
    ICollection.

    The error appears when trying to load the WebService.asmx file. The
    code builds fine.

    There are quite a few posts about how to resolve this problem however
    they all seem to pertain to custom collections. I am using the
    MembershipUserCollection and I don't feel that I have the ability to
    change how the 'out-of-the-box' version works.

    Does anybody know how to resolve this?

    Thanks, Justin.

    ASP.NET 2.0

    Here is the code for the object:

    WebService.cs

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using Demo.Content;

    /// <summary>
    /// Summary description for ResortsService /// </summary>
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public
    class ResortsService : System.Web.Services.WebService {
    public WebService()
    {
    //Uncomment the following line if using designed components
    //InitializeComponent();
    }

    [WebMethod]
    public Article GetArticle()
    {
    Article article = new Article();
    return article;
    }
    }


    Article.cs

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace Demo.Content
    {
    [Serializable]
    public class Article
    {
    private int articleID;
    private string title;
    private System.Web.Security.MembershipUserCollection authors;

    public Article()
    { }

    #region Members

    public int ArticleID
    {
    get { return this.articleID; }
    set { this.articleID = value; }
    }

    public System.Web.Security.MembershipUserCollection Authors
    {
    get { return this.authors; }
    set { this.authors = value; }
    }

    public string Title
    {
    get { return this.title; }
    set { this.title = value; }
    }

    #endregion
    }
    }
     
    , May 20, 2006
    #1
    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. xenophon
    Replies:
    1
    Views:
    3,388
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=
    Feb 28, 2006
  2. Jeff
    Replies:
    6
    Views:
    1,734
  3. Bogdan
    Replies:
    0
    Views:
    632
    Bogdan
    Sep 17, 2008
  4. Jeff
    Replies:
    1
    Views:
    1,035
  5. Replies:
    1
    Views:
    844
Loading...

Share This Page