I am writing some unit tests that serialize and deserialize all our types that can cross the WCF border to prove that all properties will cross over.
I hit a little with bytes [].
[DataContract(IsReference=true)] public class BinaryDataObject { [DataMember] public byte[] Data { get; set; } }
When I run this object through testing, I get a System.NotSupportedException: This XmlWriter does not support base64 encoded data .
Here is my Serialization method:
public static XDocument Serialize(object source) { XDocument target = new XDocument(); using (System.Xml.XmlWriter writer = target.CreateWriter()) { DataContractSerializer s = new DataContractSerializer(source.GetType()); s.WriteObject(writer, source); } return target; }
It seems to me that my serialization method should be wrong - WCF probably does not use XDocument instances and may not use System.Xml.XmlWriter instances.
Which Writer uses WCF by default? I would like to use instances of this type in my test.
Amy b source share