Search code examples
wcfdatacontractserializer

how to make WCF service use a specific DataContractSerializer constructor overload?


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.


Solution

  • 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.