ICollection must have an implementation of Add

ICollection must have an implementation of Add

Old forum URL: forums.lhotka.net/forums/t/3521.aspx


OneilT posted on Wednesday, September 12, 2007

Im currenly doing a project in VS2005 but referencing the CSLA for framework 1. I've created a web service and when trying to add the web reference im getting this error ....

"To be XML serializable, types which inherit from
ICollection must have an implementation of Add(CSLA.BrokenRules+Rule)
at all levels of their inheritance hierarchy.
CSLA.BrokenRules+RulesCollection does not implement
 Add(CSLA.BrokenRules+Rule).
"
Im a bit new to CSLA and need a bit of help Deciphering the error

JoeFallon1 replied on Wednesday, September 12, 2007

CSLA BOs are not XML serializable.

 

OneilT replied on Wednesday, September 12, 2007

By buisness class is Serializable. Currently im doing this

Buisness Class

    [Serializable]
    public class Products : BusinessCollectionBase
    {
         .............
    }


Web Method

    [WebMethod]
    public Products GetProducts()
    {
      return prod
    }

Should'nt this allow me to return the "Products" Object when the "GetProducts()" web method is called?

ajj3085 replied on Wednesday, September 12, 2007

Its not XML serialiable though, which is done differently, IIRC.

At any rate, you don't want to return an actual BO via web services.  This will be problematic for a few reasons.  Instead, you should return a DTO (Data Transfer Object) which contains the data needed by the application. 

Search on the forum, Rocky has discussed this here before.

HTH
Andy

Copyright (c) Marimer LLC