runtime icon indicating copy to clipboard operation
runtime copied to clipboard

NetDatacontractSerializer functionality on linux

Open prachi2607 opened this issue 10 years ago • 2 comments

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 avatar May 23 '16 17:05 prachi2607

@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?

shmao avatar Jun 23 '16 22:06 shmao

Closing the issue. Please feel free to re-open it if you have further questions.

shmao avatar Jun 30 '16 01:06 shmao