Error serializing Dictionary

Options
guto_thomas
edited January 2018 in DotNet
Hello,

I have a custom class (PickableInfo) that has some information on pick up items. I wrote de/serialization methods for it and registered them.

Though, when I try to serialize the type Dictionary, I get the following error:
Exception: Unexpected - cannot serialize Dictionary with value type: System.Int32
ExitGames.Client.Photon.Protocol16.SerializeDictionaryHeader (ExitGames.Client.Photon.StreamBuffer writer, System.Object dict, System.Boolean& setKeyType, System.Boolean& setValueType)
ExitGames.Client.Photon.Protocol16.SerializeDictionary (ExitGames.Client.Photon.StreamBuffer dout, IDictionary serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters)
ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType)
ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opCode, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt)
ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType)
ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted)
ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId, Boolean encrypt)
LoadBalancingPeer.OpSetPropertiesOfRoom (ExitGames.Client.Photon.Hashtable gameProperties, ExitGames.Client.Photon.Hashtable expectedProperties, Boolean webForward) (at Assets/ThirdParty/Photon/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:522)
Room.SetCustomProperties (ExitGames.Client.Photon.Hashtable propertiesToSet, ExitGames.Client.Photon.Hashtable expectedValues, Boolean webForward) (at Assets/ThirdParty/Photon/Photon Unity Networking/Plugins/PhotonNetwork/Room.cs:315)
PickableManager.GeneratePickables () (at Assets/Scripts/PickableManager.cs:73)
PickableManager.Start () (at Assets/Scripts/PickableManager.cs:19)
My question is: Must I write and register de/serialization methods for the type Dictionary? I though that writing the methods just for the custom type was enough, since I read in the serialization page that Dictionary was supported (given that V and K are serializable, which they are since V is int and K is a registered custom type).

What's the work-around for it?

Obs: I added my methods and the register call in the Photon CustomType's class.

Obs 2: I was able to write an instance of the type PickableInfo successfully to a Room property, so I guess it's not really a problem with the serialization method.

PS: I realize I posted this in the wrong section. I couldn't find the delete option.

Thank you for your attention!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @guto_thomas,

    Thank you for choosing Photon and I apologize for the delay!

    Could you share with us a short snippet (Custom type class + MonoBehaviour) to reproduce this?