DataContractSerializer has many constructor overloads, and I'd like to be able to specify how my WCF service should initialize the DataContractSerializer it uses. How would you go about doing this? Is it easier to configure this in the .config file or in C#?
A WCF service always appears to use this one by default.
If possible, please give an example of how to specify DataContractSerializer using this constructor for KnownTypes.
This MSDN forum post shows how to swap the serializer in WCF with another. You could create your own wrapper with the constructor that you want and swap it in.
I figured out how to do this. See
http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx
and
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer(v=vs.85).aspx
for guidance. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With