Missing object when deserializing
<p>I have a weird issue and am confused. I want to send a dataset over the wire and serialize it. When I deserialize, I want to retrieve the object and it's properties. However, when I DESERIALIZE (EDITED), it seems to lose the child classes associated with the base class. I created the following class:</p>

<pre><code> [Serializable]
    public class DataAttributeColumn : DataColumn, ISerializable
    {

        private string attributeName;

        [DataMember(IsRequired = true)]
        public string AttributeName
        {
            get { return attributeName; }
            set { attributeName = value; }
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("AttributeName", this.AttributeName);
        }
    }
</code></pre>

<p>Instead of using column name for a DataColumn, I wanted to extend it an add an attribute name. This all works 100% up until I send it over the wire.</p>

<p>I created the following  Test class and used Binary and DataContract serializer. </p>

<pre><code>public class Test
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        DataAttributeColumn dac = new DataAttributeColumn();

        public void CreateData()
        {
            ds.Tables.Add(dt);
            dac.AttributeName = "MyAttribute";
            dt.Columns.Add(dac);

        }

        public void SerializeBinary()
        {
            DataSet dss = new DataSet();

            BinaryFormatter dcs = new BinaryFormatter();
            ds.RemotingFormat = SerializationFormat.Xml;

            string strTempfilePath = "binary.txt";
            FileStream fs;
            using (fs = new FileStream(strTempfilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                dcs.Serialize(fs, ds);
            }

            fs = new FileStream(strTempfilePath, FileMode.Open);
            dss = dcs.Deserialize(fs) as DataSet;

            DataAttributeColumn dac2 = null;
            dac2 = dss.Tables[0].Columns[0] as DataAttributeColumn;

            if (dac2 != null)
            {
                Console.WriteLine("YOU DID IT!!!!");
            }
            //Second Serialize
            using (fs = new FileStream("binary2.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                dcs.Serialize(fs, dss);
            }
        }
        public void SerializeDataContract()
        {
            DataSet dss = new DataSet();

            Type[] knowntypes = { typeof(DataAttributeColumn), typeof(DataColumn) };
            DataContractSerializer dcs = new DataContractSerializer(typeof(DataSet), knowntypes);
            MemoryStream stream = new MemoryStream();
            ds.RemotingFormat = SerializationFormat.Xml;

            string strTempfilePath = "datacontract.txt";
            FileStream fs;
            using (fs = new FileStream(strTempfilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                dcs.WriteObject(fs, ds);
            }

            fs = new FileStream(strTempfilePath, FileMode.Open);
            dss = dcs.ReadObject(fs) as DataSet;

            DataAttributeColumn dac2 = null;
            dac2 = dss.Tables[0].Columns[0] as DataAttributeColumn;
            if (dac2 != null)
            {
                Console.WriteLine("YOU DID IT!!!!");
            }

            using (fs = new FileStream("datacontract2.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                dcs.WriteObject(fs, dss);
            }
        }
    }
</code></pre>

<p>My goal is to create an attribute and when I deserialize, I get to cast the object from DataColumn back into DataAttributeColumn in order to retrieve the "AttributeName".</p>

<p>How can I come to do this?</p>

<p>EDIT: The output after serializatiion</p>

<pre><code>&lt;DataSet&gt;&lt;xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;&lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"&gt;&lt;xs:complexType&gt;&lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;&lt;xs:element name="Table1"&gt;&lt;xs:complexType&gt;&lt;xs:sequence&gt;&lt;xs:element name="Column1" msdata:**AttributeName="MyAttribute"** type="xs:string" minOccurs="0"/&gt;&lt;/xs:sequence&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:choice&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:schema&gt;&lt;diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"/&gt;&lt;/DataSet&gt;
</code></pre>

<p>and output after deserialization:</p>

<pre><code>&lt;DataSet&gt;&lt;xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;&lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"&gt;&lt;xs:complexType&gt;&lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;&lt;xs:element name="Table1"&gt;&lt;xs:complexType&gt;&lt;xs:sequence&gt;&lt;xs:element name="Column1" type="xs:string" minOccurs="0"/&gt;&lt;/xs:sequence&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:choice&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:schema&gt;&lt;diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"/&gt;&lt;/DataSet&gt;
</code></pre>
