|
| Returning a ICollection based class (again) |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.aspnet.webservices.
| FredCK |
Hello,
Let's try again:
I implemented the ICollection inteface in "MyClassList" and it works well. Using it in a Windows Form project, I could easily do a "foreach (MyClass in MyClassList)" to list all "MyClass"'s.
But then I created a WebService with the following method:
[WebMethod] public MyClassList GetMyClassList() { MyClassList oMyClassList = new MyClassList () ; return oMyClassList ; }
When I pressed "F5" to run it, the compilation ran OK but in IE the following message appeared:
System.InvalidOperationException: You must implement a default accessor on MyNamespace.MyClassList because it inherits from ICollection
Does anyone now what to do? How can I return my ICollection based class?
Thanks in advance, Fred
|
|
|
| |
|
| |
| |
| Bob Beauchemin |
Hi Fred,
I've been able to return a class that derives from CollectionBase. In fact, I just used the typed Collection generator on gotdotnet.com to generate a simple collection of this type of sent it as a return parm from a WebService without problems. As a test, I'd try one of these collections (generator by the typed Collection generator), then compare it to your collection class. Also, you can attempt to serialize your class with the XmlSerializer to see if that works.
Hope this helps, Bob Beauchemin Click here to reveal e-mail address
"FredCK" <Click here to reveal e-mail address> wrote in message news:OkwK8hXfBHA.1996@tkmsftngp03... [Original message clipped]
|
|
|
| |
|
| |
| |
| FredCK |
Thanks a lot Bob,
Your tip made me able to understand what the "default accessor" is. It is the special property that returns an object of the collection based on its index. But not only this... for a Web Service it defines what is the BaseClass of my Collection.
This is the example of the implementation:
[Serializable()] public class MyClassList : System.Collections.ICollection { private System.Collections.ArrayList colMyClass = new System.Collections.ArrayList() ;
// Default Accessor Implementation public MyClass this[int index] { get { if (! bIsLoaded) { Reload() ; } return ((MyClass)(colMyClass [index])); } set { /* Do Nothing */ } }
Thanks again, Fred
"Bob Beauchemin" <Click here to reveal e-mail address> wrote in message news:etsgwaqfBHA.1564@tkmsftngp02... [Original message clipped]
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|