Reputation: 1031
This is a class in a c# application:
[Serializable()]
public class AAA
{
private List<AAA> arr;
private AAA parentA;
public List<AAA> Arr
{
get { return arr; }
set { arr = value; }
}
public AAA ParentA
{
get { return parentA; }
set { parentA = value; }
}
}
when I try to serialize this class by XMLSerializer and the list "arr" or "parentA" are containing a value the serialization fail to write the XML.
Can you please uggest a way how to resolve it?
Please attach code example.
Note: I must use XMLSerializer, Not any other serializer.
10x
Upvotes: 1
Views: 139
Reputation: 170
add to the class attribute
[XmlInclude(typeof(AAA))] public class AAA
and public field like
[XmlArray("AAAarray")] [XmlArrayItem("Param", typeof(AAA))] public IList arr { get; set; }
Upvotes: 1
Reputation: 6765
Missing attribute? And the variable might have to be public.
[Serializable()]
public class AAA {
public List<AAA> arr;
public AAA parentA;
}
Upvotes: 2