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
-
Monday, November 12, 2007 4:03 PM
As often happens, after the post I found the error. I did not make a call to base.GetObjectData() in my GetObjectData() method.
- Marked As Answer by Amadeo Casas - MSFTModerator Tuesday, February 10, 2009 10:06 PM
-
Saturday, May 05, 2012 7:01 PM
If you ever need to surpress the error, checkout this note from http://lifeelement.com.
SerializationException Member was not found
http://lifeelement.com/news/serializationexception-member-was-not-found/.- Edited by Tres Oliver Saturday, May 05, 2012 7:01 PM

