Question

I would like to create an [CustomDataMember] attribute that override the formatter behavior of DataContractSerializer through an IOperationBehavior. I have followed the instructions given by Aaron Skonnard but when I call the DCS serializer, the custom behavior does not get neither instantiated nor called.

Obviously, I am missing something, probably at the level of the constructor call of DataContractSerializer. Does anyone knows what could be done to get the behavior properly injected in the DCS?

Was it helpful?

Solution

Aaron's instructions don't apply. Those instructions are for switching which serializer WCF uses when dealing with message conversion. You're instantiating the serializer directly. DataContractSerializer doesn't really support much customization of the process- it's supposed to be dirt simple, not flexible. If you need flexibility, use XmlSerializer/IXmlSerializable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top