要实现 XML 可序列化,从 ICollection 继承的类型必须具有 Add 的实现
我有来自现有项目的 CSLA(1.x 框架)对象,我试图在新的 .Net 4.0 项目中使用它。这些对象正在生产中使用,如果没有 2 组对象,我确实无法将它们转换为 2.x 或 EF。
在我的 c# webservice 中(当我尝试运行它时)我收到以下错误:
要实现 XML 可序列化,从 ICollection 继承的类型必须 在所有级别都有 Add(objectname.object) 的实现 他们的继承层次结构。 objectname.objectList 没有 实现 Add(objectname.object)。
正如我所说,这些对象是用 vb.net 编写的 CSLA 对象。我不知道该去哪里看这个。这是 .Net 4.0 尝试与 CSLA 1.x 对话的问题还是 Web 服务问题(因为这些对象最初从未使用过 Web 服务)?
有谁知道我应该去哪里解决这个问题?我应该建议转换为 CSLA 2.x 吗?
任何建议表示赞赏!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 XmlSerializer 的限制;如果某些内容看起来像数据列表,它将希望通过 Add 方法向其中添加项目。
如果您有权访问这些对象,请考虑添加这样的方法。我不记得它是否想要 Add(object) 与 Add(SomeType) 所以两者都尝试一下。
如果您无法控制这些对象......那就很难了。为对象编写一个新的 DTO 层比尝试以某种方式修补它要快。
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.