Why is Message.data null?

I’ve a very simple class:

    [Serializable]
    public class TryggSyncMsgCommandRequest
    {
        public MsgCommandTypes MsgCommandType { get; set; }
        public object[] RequestParameters { get; set; }
 
        public TryggSyncMsgCommandRequest(MsgCommandTypes msgCommand, params object[] parameters)
        {
            this.MsgCommandType = msgCommand;
            this.RequestParameters = parameters;
        }
 
        public void SendToEventServer(MessageCommunication msgCom)
        {
            msgCom.TransmitMessage(new Message(TryggSyncDefinition.TryggSyncMsgCommandRequest, this), msgCom.ServerEndPointFQID, null, null);
        }
    }

From the SmartClient I send messages like this:

new TryggSyncMsgCommandRequest(MsgCommandTypes.OwnershipStatus).SendToEventServer(messageCommunication);

But when I send it with a object parameter:

            myUser = new OperatorUser(ls.UserName, ls.Guid);
 
            new TryggSyncMsgCommandRequest(MsgCommandTypes.TakeOwnership, myUser).SendToEventServer(messageCommunication);
 
 
...
 
    [Serializable]
    public class OperatorUser
    {
        public string DisplayName { get; set; }
        public Guid ID { get; set; }
 
        public OperatorUser(string name, Guid id)
        {
            this.DisplayName = name;
            this.ID = id;
        }
    }

Message.data is null at the Event Server. How do I troubleshoot this?

Edit: Message.data is NOT null if I replace the myUser class object with myUser.DisplayName, so the parameter is only 1 string.

When you pass a class, the dll “in both ends” must be the same, even the same build! Can this be the cause? (Issue seen with the Chat sample)

It is the same DLL/project. My temporary solution is to serialize the class before sending it and deserializing on arrival.

I’m unfortunately running into this problem with a List aswell.

Felix, I have tried to make a sample using “List” in the Data field, and that works fine for me. I also tried to compile one version with .Net 4.6 and another wíth .Net 4.7 – to see if that would break, but that also works fine. Can you share the code that does not work, and describe more about how you compile and run the test - e.g. where is the sample executed.

The object that’s being sent is a instance of the class TryggSyncMsgCommandRequest, which is serializable. The data in the message is stored in the object array “RequestParameters”. It seems like whenever the array contains something that isn’t a basic datatype, the whole message.Data object is null.

Please try it out with my class at the top and see if that work’s.

I cannot get “object[]” to work with classes in the object array.

You will need to do your own serializer if you need to pack a list of verying types, and store the resulting string in the Data field.