TheCodeKing / XDMessaging.Net

Easy-to-use, zero configuration solution for PubSub messaging across application and network boundaries.
http://thecodeking.co.uk/project/xdmessaging/
Other
61 stars 22 forks source link

Sending Custom Object #20

Open MikeFederico opened 3 years ago

MikeFederico commented 3 years ago

I am trying to send a Serialized custom object through a channel but in the MessageRecieved event the object is null. What is missing? I am using TypedDataGram item = e.DataGram;.

Any help?

gdcircuit commented 3 years ago

I had the same issue. It comes from the fact that the class reference is passed with the assembly info of the sender. So, if you simply have a copy of the class in both apps, the receiver will not be able to deserialize the object because it doesn't have access to the sender. Simply add the assembly of the sender(exe,dll) as a reference to the receiver, and remove the copy of the class in the receiver. With the reference to the original class, via the senders assembly, the receiver will build fine. And when it gets the inbound message it has the reference to the senders assembly to decode the message.