if(objectHasPropertiesOfAnInterfaceType) { DoNotUseXmlSerializer(saidObject); }

A short remark which can save you tremendous trouble and hours of hairpulling: if you want to test if your objects can be serialized, do not, I repeat, do not, use the XmlSerializer class when your object has properties which return / accept an interface. The Soap serializer will work with these properties just fine, but the XmlSerializer will barf it can't handle interfaces. I just spend an hour rewriting some interfaces, crawling through google groups and finally discovered the XmlSerializer class isn't about serializing at all.

Just so you know this and you won't make the same mistake I made :)

PS: I used the XmlSerializer class to create an XML representation of an object very easily, that turned out to be not that erm.. easy when you have properties which accept/return an interface.

No Comments