Serialization of entity with custom class

Posts   
 
    
can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 28-Jul-2010 16:43:00   

Hello,

I am having some problems using the explicit serialization of an LL entity which has been extended to include a LIST<ErrorData>, where ErrorData is a custom class written by us, extended via a partial class.

If I remove the added member variable LIST<ErrorData> from the CommonEntityBase, then writexml and readxml work fine.

As soon as I extend the entity, with the LIST<ErrorData>, and the ErrorData class is marked as [serializable], then I received the following error:

Object of type 'System.String' cannot be converted to type 'System.Collections.Generic.List`1[OneShop.Mc.DAL.CustomBusinessEntityClasses.ErrorData]'.

This error occurs regardless of whether I use Compact, Compact25 or no XML optimization hint on the WriteXML method.

Any thoughts?

Thanks.

Can1

p.s. I am using LL V2.6

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Jul-2010 17:03:10   

Do you get this error when reading the Xml, right? Would you please post the code that writes and reads the xml?

Have you implemented ISerializable in the ErrorData class.

can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 05-Aug-2010 15:33:26   

I found in the documentation a note that when you serialize entities with custom members and properties, you must do the serialization of the custom class members manually via override the serialization events. That resolved the issue.

Can1