NetDatacontractSerializer functionality on linux
Hi, We are trying to port our codebase to Linux. Right now, we are using NetDatacontractSerializer to send exception over wire as the client doesn't know the type of exception beforehand. Since NetDatacontractSerializer is no longer present in coreclr, we tried using DataContractResolver . However, since type information is not embedded in the serialized object, it throws an exception when we are trying to deserialize. In full CLR, DataContractResolver with dataContractSerializer would've solved the problem. Though DataContractResolver is available in coreCLR, there is no constructor of DataContractResolver using DataContractResolver.
Is this the intended behavior. Can you help me out?
@prachi2607, DataContractSerializer has constructors that take DataContractSerializerSettings as parameter, and you can set DataContractResolver in the settings. For example,
var myresolver = new MyResolver(); // MyResolver : DataContractResolver
var settings = new DataContractSerializerSettings() { DataContractResolver = myresolver};
var serializer = new DataContractSerializer(type, settings);
Can you see if this would work for you?
Closing the issue. Please feel free to re-open it if you have further questions.