Serialize error from user control
<p>I have created a user control (CheckedDirTree) that exposes a CheckedFolder property which in turn returns an IEnumerable of the FullPath property of Nodes checked in the control. Something like this:</p>

<pre><code> public IEnumerable&lt;string&gt; CheckedFolders
    {
        get
        {
            foreach (TreeNode node in treeView1.Nodes[0].DescendantNodes())
            {
                if(node.Checked &amp;&amp; !node.FullPath.Equals(_directoryRoot))
                    yield return node.FullPath;
            }
        }
    }
</code></pre>

<p>This is being fed to another class's (SymbolsShareDto) Folders property after this cntrol is shown in a grid and the user has checked some folders:</p>

<pre><code>using (var dirControl = new CheckedDirForm(symbolsShare))
                {
                    if (dirControl.ShowDialog() == DialogResult.OK)
                    {
                        var symbolsShareObj = bindingSourceShare.Current as SymbolShareModel;
                        if (symbolsShareObj != null) symbolsShareObj.Folders = dirControl.CheckedFolders;
                    }
                }

[DataContract]
public class SymbolShareDTO
{
    public SymbolShareDTO(){}

    [DataMember]
    public string Share { get; set; }
    [DataMember]
    public string BackupTo { get; set; }
    [DataMember]
    public IEnumerable&lt;string&gt; Folders { get; set; }

    public override string ToString()
    {
        return string.Format("Share: {0}{1}BackupTo: {2}{3}Folders: {4}", Share, Environment.NewLine, BackupTo,
                             Environment.NewLine, Folders.Count());
    }
}
</code></pre>

<p>However when I serialize the SymbolsShareDto, I'm getting an error saying </p>

<pre><code>CheckedDirTree+&lt;get_CheckedFolders&gt;d__6' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
</code></pre>

<p>Any thoughts ? Do I need to return a new List from CheckedFolders property instead.</p>

<p>thanks
Sunit</p>
