Cyberactiva - webmaster tutorials, programming and videogames tricks

webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu
  

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

Custom object with a System.Web.Security.MembershipUserCollection property - "implement a default accessor" error
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 description for ResortsService
///

[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.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
Thanks for the reply Tasos.

I've solved the problem by implementing my own typed collection that
wraps the System.Web.Security.MembershipUserCollection.

Cheers.


Register for freeMembers Area
Web MarketingLast Web Marketing
Web MarketingLast Programming Tips
Web MarketingLast News


Web Marketing Links and links exchange .