3

I have CSLA (1.x framework) objects from an existing project that I'm trying to use in a new .Net 4.0 project. The objects are being used in production and I really can't convert them to 2.x or EF without having 2 sets of objects.

In my c# webservice (when I try to run it) I am getting the following error:

To be XML serializable, types which inherit from ICollection must
have an implementation of Add(objectname.object) at all levels
of their inheritance hierarchy. objectname.objectList does not
implement Add(objectname.object).

Like I said these objects are CSLA objects written in vb.net. I don't know where to look on this one. Is it an issue of .Net 4.0 trying to talk to CSLA 1.x or is it a web service issue (as these objects never used web services originally)?

Does anyone have an idea about where I should look to figure out this issue? Should I suggest converting to CSLA 2.x?

Any suggestions are appreciated!

webdad3
  • 8,893
  • 30
  • 121
  • 223

1 Answers1

7

This is an XmlSerializer limitation; if something looks like a list of data, it will want to Add items to it via the Add method.

If you have access to those objects, consider adding such a method. I can't recall whether it wants Add(object) vs Add(SomeType) so try both.

If you don't have control over those objects... it will be hard. It would be quicker to write a new DTO layer for the objects than to try to patch it somehow.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Thank you for your answer... What does DTO stand for? I do have control over those objects however, they are also being used in another project which would mean I would have to include more people in this type of change. So your DTO option is intriguing... – webdad3 Nov 10 '10 at 19:23
  • @Jeff - Data Transfer Object - i.e. a set of classes *specifically* for the purposes of serialization – Marc Gravell Nov 10 '10 at 21:35
  • @Jeff - but in this case it sounds like you should be able to just add the missing `Add`? – Marc Gravell Nov 10 '10 at 21:35