title: How can I fix circular A circular reference was detected while serializing?
body: <p>I am trying to serialize a tree structures using the objects provided below. I need to have the list of children serialized with the object, but I can live without the parent (since I can just fix that on de-serialization). </p>
  
  <p>The problem I am having is that regardless if I have <code>[XmlIgnore]</code> or not, I still get this error. </p>
  
  <blockquote>
    <p>A circular reference was detected while serializing an object of type
    'DataEntry'</p>
  </blockquote>
  
  <p>If I change the 'getter/setter' for the 'Parent' property to do nothing, it all work. </p>
  
  <pre><code>[XmlIgnore]
          public DataEntry Parent 
          {
              get { return null; }
              set {} 
          }
  </code></pre>
  
  <p>But I need this Parent reference to be available at a later stage. </p>
  
  <pre><code>public class DataEntry
      {
          [XmlIgnore]
          public DataEntry Parent { get; set; }
  
          public List&lt;DataEntry&gt; Children { get; set; }
  
          private List&lt;String&gt; mValues = new List&lt;String&gt;();
          public List&lt;String&gt; Values
          {
              get
              {
                  return mValues;
              }
              set
              {
                  mValues = value;
              }
          }
  
          private String mName = String.Empty;
          public String Name
          {
              get { return mName; }
              set
              {
                  mName = value;
              }
          }
  
          /// &lt;summary&gt;
          /// Data entry
          /// &lt;/summary&gt;
          /// &lt;param name="partent"&gt;parent node - if root node give no parent&lt;/param&gt;
          /// &lt;param name="name"&gt;Name of property&lt;/param&gt;
          /// &lt;param name="values"&gt;Values for this property&lt;/param&gt;
          public DataEntry(DataEntry partent, String name, List&lt;String&gt; values)
          {
              Children = new List&lt;DataEntry&gt;(); 
              Parent = partent;
              mValues = values;
              mName = name;
          }
  
          /// &lt;summary&gt;
          /// Add a child to this node
          /// &lt;/summary&gt;
          /// &lt;param name="child"&gt;&lt;/param&gt;
          public void AddChild(DataEntry child)
          {
              Children.Add(child);
          }
      }
  </code></pre>
  
  <p>Any help would be much appreciated.</p>