473,386 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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>
/// 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 '06 #1
2 3814
Hello Justin,

I am afraid you can't do that. Either you will have to subclass
MembershipUserCollection to provide an indexer accessor (I don't know
if you can) or create a typed collection deriving from CollectionBase.

Tasos

May 20 '06 #2
Thanks for the reply Tasos.

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

Cheers.

May 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement is wrapped in try/catch error handling statement....
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
6
by: Paul Turley | last post by:
Does anyone have some sample script to "press" a button or image button when the user presses the Enter key? I see this behavior on a lot of web pages but I'm not finding any samples. Thx --...
4
by: Ueslei R. Valentini | last post by:
Hi! I'm using Windows Authentication in my application, restricting permissions with authorization for specific users. But when someone try to access and don't have permissions, the default page...
0
by: ravescar | last post by:
I am currently working on an generic error collection mechanism in ASP.NET2.0 written using C# that can catch unhandled exception on a web application in application level. it automatically save an...
15
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
6
by: Smithers | last post by:
Just looking to compile a list of "all the ways to implement events". I'm NOT looking to get into the merits or mechanics of each in this thread... just want to identify them all - good, bad, and...
9
by: Trapulo | last post by:
Hello, with ASP.NET 2.0 Ajax every unexpected error is managed client-side with a popup that reports the error to the user. In ASP.NET 3.5 this behavor has been changed: how can I have a similar...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.