Problem changing class field from string to Class
-
I am maintaining an application that uses the XmlSerializer to import and export data. I would like to make some modifications to the internals of the application, but I need to maintain backward compatibility with older XMLs that customers may have. Essentially I'm trying to change [XmlAttribute] public string CashFlowType; , which contains the name of the type, to this [XmlAttribute] public CashFlowType CashFlowType; , which would be an object that encapsulates all of the details of the object instead of just the name. The problem is that the Serializer can't put the complex type CashFlowType into an XmlAttribute, and rightly so. The ideal solution would be to use [XmlElement] and write out the fields that I need to deserialize, but for the sake of maintaining backward compatibility, I cannot change the attribute to an element. I have tried setting all of the fields of CashFlowType to [XmlIgnore] and I overrode ToString() in the hopes that the serializer would put the result of ToString in the attribute but it throws an exception just the same. If anyone has any ideas it would be greatly appreciated. Thanks, Jason