XML serialization not working for Interfaces


(Devindran) #1


public interface ISomething : IEvent
IDetails Details { get; }

public interface IDetails
string S { get; }
string T { get; }

If I were to publish a message with the concrete implementation of ISomething, the resulting XML appears as <Something>
(added * to get around formatting)

Where none of the properties that are part of IDetails are included. If I instead switch out IDetails with Details, then everything works fine.

Is there a way to initialize the XmlSerializer transport and provide the known types to the serializer so that I can work with only the interface?

(Tim Bussmann) #2

What version of NServiceBus are you using?

(Devindran) #3

Using version 7 beta.

(Tim Bussmann) #4

I was able to reproduce your described scenario. I noticed that not only the XML doesn’t contain the properties, but it also failed to deserialize the message at all on the receiver. Are you experiencing the same behavior?

Is there a specific reason you’re using an interface as the properties type?

(Tim Bussmann) #5

hey @devindran, looking again at your messages, I realized that you need to add setters to all the interfaces to get the message to serialize correctly. Can you verify whether that resolves your issue?