Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > ICollection default accessor

Reply
Thread Tools

ICollection default accessor

 
 
Dale
Guest
Posts: n/a
 
      11-21-2006
I am returning a custom collection from a web service in .Net 2.0. When I
try to create a WebReference to that web service in the designer, I get the
following error:

You must implement a default accessor on AccountingBL.ProductCollection
because it inherits from ICollection.

I have no idea what they mean by default accessor. Any thoughts?

Thanks,

Dale

--
Dale Preston
MCAD C#
MCSE, MCDBA
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-22-2006
Hello Dale,

As for the "default accessor", it means the default propety that used to
access the item in a collection based on index key. e.g. In the following
custom collection class, the " public Int16 this[int index]" property is
the default accessor:

=====================
public class Int16Collection : CollectionBase
{
public Int16Collection()
{

}

public Int16 this[int index]
{
get
{
return ((Int16)List[index]);
}
set
{
List[index] = value;
}
}

public int Add(Int16 value)
{
return (List.Add(value));
}

.............................
========================

Are you using VB.NET or C#, if convenient, would you also provide the
complete custom collection class code here or a simplified test class which
also suffer the problem?

Based on my research, there are some one who suffer the same issue, and
mostly are in webservice or other XML Serialization scenario. You can
verify the above default accessor and also add a default constructor(no
parameter constructor) for your custom collection class to see whether it
helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Dale
Guest
Posts: n/a
 
      11-22-2006
Steven,

Thanks for your help. The this[int index] indexer solved the problem. I
had an indexer in the form of this[object obj] which also handled obj if it
was an int. That's why I couldn't figure out the "default accessor"
statement in the exception. Now I know the difference between the two forms.

Just FYI, I am using C#. The collection class I am using is based on Natty
Gur's blog article at
http://weblogs.asp.net/ngur/articles/144770.aspx.

I have been using collection classes based on that since he first published
the article over 2 years ago. Until now, I have never run into this problem
but this is the first time I am returning the custom collection from a web
service rather than simply return an array of my objects from the web service.

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA


"Steven Cheng[MSFT]" wrote:

> Hello Dale,
>
> As for the "default accessor", it means the default propety that used to
> access the item in a collection based on index key. e.g. In the following
> custom collection class, the " public Int16 this[int index]" property is
> the default accessor:
>
> =====================
> public class Int16Collection : CollectionBase
> {
> public Int16Collection()
> {
>
> }
>
> public Int16 this[int index]
> {
> get
> {
> return ((Int16)List[index]);
> }
> set
> {
> List[index] = value;
> }
> }
>
> public int Add(Int16 value)
> {
> return (List.Add(value));
> }
>
> .............................
> ========================
>
> Are you using VB.NET or C#, if convenient, would you also provide the
> complete custom collection class code here or a simplified test class which
> also suffer the problem?
>
> Based on my research, there are some one who suffer the same issue, and
> mostly are in webservice or other XML Serialization scenario. You can
> verify the above default accessor and also add a default constructor(no
> parameter constructor) for your custom collection class to see whether it
> helps.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-23-2006
Thanks for your reply Dale,

Yes, some problem won't occur until being in a particular context. For
example, the custom collection issue here only occurs in XML Serialization
context. Anyway, glad that you've got it working now.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot add property into Class when implementing ICollection interface Pinkesh ASP .Net 0 01-12-2007 10:30 AM
How do you reference this property: System.Collections.Generic.ICollection<DataSource> Polaris431 C Programming 2 11-09-2006 11:08 AM
Custom object with a System.Web.Security.MembershipUserCollection property - "implement a default accessor" error justin.drerup@gmail.com ASP .Net Web Services 0 05-20-2006 08:38 AM
DataGrid Paging / ICollection Error [JSCRIPT] HP ASP .Net 1 02-26-2005 10:01 AM
method type ICollection returns Dataview Janus Knudsen ASP .Net 1 07-06-2004 06:04 AM



Advertisments