Member not found error when serializing a Dictionary<> derived object

Locked Member not found error when serializing a Dictionary<> derived object

  • Monday, November 12, 2007 3:45 PM
     
     

    I am trying to serialize a class that inherits from Dictionary<string, anObject> and am getting a SerializationException…

     

    "Member 'Version' was not found."

     

    My object does not contain a “Version” member. I assume that it is a private member of the Dictionary<>.  I would be grateful for any help in correctly implementing an object derived from Dictionary<>.

     

    TIA

     

    David

     

    Here is how I am implementing the object:

     

        [Serializable()]

        public sealed class InputData : Dictionary<string, MmpControlDataBase>, ISerializable

        {

            #region Member Variables

            private int numberOfFlights;

            private int numberOfRuns;

            private double h2oFactor;

            private double co2Factor;

            private double soxFactor;

            private string database;

            private string date;

     

            // create the single instance

            private static InputData inputData = new InputData();

            #endregion Member Variables

     

            private InputData()

            {

            }

     

            private InputData(

                System.Runtime.Serialization.SerializationInfo info,

                System.Runtime.Serialization.StreamingContext context)

                : base(info, context)

            {

                numberOfFlights = info.GetInt32("numberOfFlights");

                numberOfRuns = info.GetInt32("numberOfRuns");

                h2oFactor = info.GetDouble("h2oFactor");

                co2Factor = info.GetDouble("co2Factor");

                soxFactor = info.GetDouble("soxFactor");

                database = info.GetString("database");

                date = info.GetString("date");

            }

     

            void ISerializable.GetObjectData(

    SerializationInfo info,

    StreamingContext context)

            {

                if (info == null)

                    throw new ArgumentNullException("info");

     

                info.AddValue("numberOfFlights", numberOfFlights);

                info.AddValue("numberOfRuns", numberOfRuns);

                info.AddValue("h2oFactor", h2oFactor);

                info.AddValue("co2Factor", co2Factor);

                info.AddValue("soxFactor", soxFactor);

                info.AddValue("database", database);

                info.AddValue("date", date);

            }

     

All Replies