I am unable to send an object of a class i created in a message. I have only tried to send strings as messages earlier.
Is it even possible to send objects in a message?
If yes, what is the correct way to do this?
I am unable to send an object of a class i created in a message. I have only tried to send strings as messages earlier.
Is it even possible to send objects in a message?
If yes, what is the correct way to do this?
Yes, it is possible. Below is short and simple example. When you receive message you should cast Data to type of your object.
Message msg = new Message(PluginDefinition.TabUserControlLoaded);
msg.Data = yourObject;
_messageCommunication.TransmitMessage(msg, null, null, null);
This is what I have been trying to do. But i get this exception everytime: Object reference not set to an instance of an object.
It seems like the object that I am sending disappears.
Thats why I had to ask if it even was possible.
_messageCommunication.TransmitMessage(new Message(ABBPlugin_v1Definition.MsgToView1){ Data=_steinsvik }, null, null, null);
_steinsvik is the object. Sending this from the background, to the ViewItemWpfUserControl
if (message.Data is Steinsvik)
{
_steinsvik=(Steinsvik)message.Data;
}
Any tips of what might be wrong?
Please try and explore Chat sample, this sample might be helpful -
https://doc.developer.milestonesys.com/html/index.html?base=samples/chat.html&tree=tree_1.html