1

I am using a class which implements ISerializable but does not have a parameterless constructor. The class is from EmguCV library:

[Serializable]
public class DenseHistogram : UnmanagedObject, ISerializable, IEquatable<DenseHistogram>
{
    public DenseHistogram(int binSize, RangeF range);
    public DenseHistogram(int[] binSizes, RangeF[] ranges);
    public DenseHistogram(SerializationInfo info, StreamingContext context);
}

As you may guess I get a "Emgu.CV.DenseHistogram cannot be serialized because it does not have a parameterless constructor." exception. I know that -and why- I need the parameterless constructor but it kind of makes me confused since the class implements ISerializable.

paul simmons
  • 5,568
  • 13
  • 51
  • 78

1 Answers1

1

This is for binary serialization through the BinaryFormatter, not the more familiar serialization through XmlSerializer.

Some information here: Custom serialization. By default binary serialization serializes the fields of classes, ISerializable allows this to be overridden, for instance when serializing between different versions.

dbc
  • 104,963
  • 20
  • 228
  • 340