I have a shallow, but wide class heirarchy. I have one base class with several derived classes.
During serialization, I pass a reference to the XmlSerializer. The reference never points to the base class; it points to one of the derived classes.
So when I attempt to serialize
On this last line, the execution fails with a run time error:
"The type LibraryName.Classname was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
I took this suggestion and added
to the Base class definition. The code now executes fine. The problem is, what if I do not own the base class definition? What if I do not have access to the base class definition? Isn't there a better way to do this????