I am trying to migrate some WCF code to target .NET Standard 2.0 and am using System.ServiceModel.Primitives version 4.5.0-preview1. The DataContractSerializerOperationBehavior no longer exposes a DataContractSurrogate property. I know a surrogate can be used with a DataContractSerializer via the DataContractSerializerExtension, however I don’t see a way to utilize it with DataContractSerializerOperationBehavior.
public class MyDataContractSurrogate : ISerializationSurrogateProvider
{
....
}
DataContractSerializer ser = new DataContractSerializer(obj.GetType());
ser.SetSerializationSurrogateProvider(new MyDataContractSurrogate());
Is there a way to use a DataContractSurrogate in this version of WCF?
I have tried replacing the default DataContractSerializerOperationBehavior operation behavior by inheriting from DataContractSerializerOperationBehavior and returning a DataContractSerializer with an attached surrogate from the CreateSerializer method without any luck.