473,803 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom object with a System.Web.Secu rity.Membership UserCollection 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.Secu rity.Membership UserCollection 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
MembershipUserC ollection 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.Collecti ons;
using System.Web.Serv ices;
using System.Web.Serv ices.Protocols;
using Demo.Content;

/// <summary>
/// Summary description for ResortsService
/// </summary>
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
public class ResortsService : System.Web.Serv ices.WebService
{
public WebService()
{
//Uncomment the following line if using designed components
//InitializeCompo nent();
}

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

using System;
using System.Collecti ons.Generic;
using System.Text;

namespace Demo.Content
{
[Serializable]
public class Article
{
private int articleID;
private string title;
private System.Web.Secu rity.Membership UserCollection authors;

public Article()
{ }

#region Members

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

public System.Web.Secu rity.Membership UserCollection 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 3853
Hello Justin,

I am afraid you can't do that. Either you will have to subclass
MembershipUserC ollection 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.Secu rity.Membership UserCollection.

Cheers.

May 22 '06 #3

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

Similar topics

2
7983
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 close out the form, in which case I can look at the entire set of values and see if they're OK. So, I have this code. for the "Before Update" event: if (their variables are inappropriate) then msgbox "You've entered bad variables (or some...
5
8771
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. This works fine. When i try to implement the "SqlTransation" class, the code does not work as the SqlTransation object is out-of-scope in the catch statement, and/or, after the USING statement ends, the sql connection object is automatically...
8
3520
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 cannot load/unload/reload extensions into my large and slow-to-load application during development without restarting the process then the disadvantages may outweigh the advantages. I've got a mixed-mode program in which I create a new AppDomain...
6
8229
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 -- Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician paul@createsolutions.net
4
2016
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 "Access is Denied" appears... Can I figure out this and show my own page? HSH Ueslei
0
1505
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 html output with tables containing environmental detail(client browser detail, form request detail etc) to a predefined Error folder. we all know that when an exception occurs in a web application, and you have not set a custom error page in...
15
12553
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 property. Where is it? Or mabye change the other thing,No?Thanks ! Simon
6
4813
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 ugly. Here's what I have so far 1. Implement via the 'event' keyword (with associated delegate, etc) 2. Expose a private delegate via a public property (really a "roll yer own" version of the 'event' keyword method).
9
2084
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 behavor? I'd like that every exception raised from ASP.NET runtime during an asyncpostback is managed in client side with a popup that reports the error message. thanks
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.