[The constructor of the deserialization "XXX" type object is not found.] The error is generally because the class to be deserialized or its parent class (for example, inherits the dictionary class) implements the iserializable interface without serializing the constructor, at this time, you only need to add the serialization constructor to deserialize it. Note that a class or its parent class implements the iserializable interface, which indicates that custom serialization is enabled, and the serialization constructor and getobjectdata function must be compiled according to the custom serialization rules, see the following two examples.
[Serializable] class test: iserializable // The class implementing the iserializable interface {public test () {}// the class implementing the iserializable interface must contain a serialized constructor; otherwise, an error occurs. Protected test (serializationinfo, streamingcontext context) {value = info. getboolean ("test_value") ;}# region iserializable member public void getobjectdata (serializationinfo info, streamingcontext context) {base. getobjectdata (Info, context); info. addvalue ("test_value", value) ;}# endregion public bool value {Get; Set ;}}
[Serializable] class test: dictionary <string, string> // The parent class implements the iserializable interface (Dictionary implements the iserializable Interface) {public test () {} // if the parent class implements the iserializable interface, the subclass must also have a serialized constructor. Otherwise, an error occurs during deserialization. Protected test (serializationinfo, streamingcontext context): Base (Info, context) {value = info. getboolean ("test_value");} public override void getobjectdata (serializationinfo info, streamingcontext context) {base. getobjectdata (Info, context); info. addvalue ("test_value", value) ;}public bool value {Get; Set ;}}