I am writing a plugin for an application that exposes an abstract base class type, and from which my class is supposed to be derived. When it stores my instantiated class away for later retrieval, the application uses its XML serializer to serialize the class, without exposing the serializer to me.
Obviously, when it tries to serialize my class, the XML serializer throws a System.InvalidOperationException
exception, with the message
"The type YourDerivedType was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
Since I don't have access to the base class, I cannot decorate it with the XmlInclude
attribute, and because the application uses its own serializer, I cannot use a new XmlSerializer
, pass my derived type to its constructor, and then use this XmlSerializer to serialize.
Any suggestions on how (or whether!) I can get my class serialized and make this exception go away?