To be XML serializable, types which inherit from I

2019-07-01 10:45发布

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!

1条回答
Evening l夕情丶
2楼-- · 2019-07-01 11:29

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.

查看更多
登录 后发表回答