How to serialize objects of type dictionary and dictionary using MessagePack with il2cpp
So I seem to have hit this roadblock in building my app where an attempt to serialize these two objects of called "Dictionary stat" and "Dictionary properties" just seem impossible. my code is sequential of course and an exception is returned at the point of serializing "stat" which comes before the serialization of"properties", meaning the code never even reaches the point of serializing properties dictionary, thus my first challenge is getting past serializing the stat dictionary. I'm asking both questions so I won't have to come back to type another question.
Error Message: (UnityFramework)[8340] : FormatterNotRegisteredException: System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not registered in resolver: MessagePack.Resolvers.StaticCompositeResolver
Things I've tried: Initialized messagePack composite resolvers before attempting to serialize or deserialize anything.:
//initialize messagepack
StaticCompositeResolver.Instance.Register(
MessagePack.Resolvers.GeneratedResolver.Instance,
MessagePack.Resolvers.StandardResolver.Instance,
MessagePack.Resolvers.BuiltinResolver.Instance
);
var option = MessagePackSerializerOptions.Standard.WithResolver(StaticCompositeResolver.Instance);
MessagePackSerializer.DefaultOptions = option;
The generated resolver does seem to cover the Property class, however, the code never reaches there and it throws an error when serializing the "stat" dictionary which comes before the "properties" dictionary. Neither the standard resolver nor the built-in resolver solves the challenge of serializing the "stat" dictionary.
static GeneratedResolverGetFormatterHelper()
{
lookup = new global::System.Collections.Generic.Dictionary<Type, int>(3)
{
{ typeof(global::AchievementManager.Property_ActivationRules), 0 },
{ typeof(global::AchievementManager.Property_UpdateRules), 1 },
{ typeof(global::AchievementManager.Property), 2 },
};
}
What in the world am I supposed to do to get message pack to serialize the two dictionaries. Any help in the right direction would be much appreciated. Unity Version:2019.4.17f1 ScriptingBackend: IL2CPP Api Compatibility Level: .Net 4.x Strip Engine Code: False Build Platform: IOS and Android
Your answer
Follow this Question
Related Questions
Xcode - Mach-O Linker Error after upgrade to Unity 2019.4 (LTS) 0 Answers
Null Exception while serialize json string into txt file 0 Answers
iOS crash during game play. il2cpp related 0 Answers
iOS, Photon and IL2CPP build error 0 Answers
How Can I deserialize List type data from a Binary file? 0 Answers