Unable to serialize CSLA object

Unable to serialize CSLA object

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


boo posted on Monday, March 05, 2007

   When trying to XML serialize a business object we are receiving the following error:

System.InvalidOperationException: Cannot serialize member 'Csla.Core.BusinessBase.BrokenRulesCollection' of type 'Csla.Validation.BrokenRulesCollection', see inner exception for more details. --->  System.InvalidOperationException: Csla.Validation.BrokenRule cannot be serialized because it does not have a parameterless constructor..

Can business objects only be binary serialized?  Is there a work around for this?

BTW...I did override the BrokenRulesCollection and added the XmlIgnore attribute but I still get this error, which puzzles me because the XmlSerializer shouldn't even be looking at this property (maybe because it's overriden versus going into the CSLA object itself and doing it there?) but I'm still stuck with the problem.

RockfordLhotka replied on Monday, March 05, 2007

This is one of those questions that should find its way into the FAQ.

No, the XmlSerializer has too many limitations to make it practical for use with CSLA-style objects.

Look at Chapter 11 for some examples of how to define an XML interface for your objects, and how to use DataMapper.Map() to help get the object data into and out of your XmlSerializable message objects.

ajj3085 replied on Monday, March 05, 2007

I added this response to the FAQ.  Let me know how it can be improved.

Andy

Copyright (c) Marimer LLC