Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessagePack deserialize exception FormatterNotRegisteredException

I have a unity project where i need to be able to deserialize really fast. I tried MessagePack. I followed the tutorial but when the deserialization is triggered i receive this error:

FormatterNotRegisteredException: DeserializedObject is not registered in resolver

This is my class:

using UnityEngine;
using MessagePack;

[MessagePackObject]
public class DeserializedObject
{
   [Key(0)]
   public SortedDictionary<string, SortedDictionary<string, ushort[,]>> features;

}

i call this from other class like this:

z-represents the bytes.

DeserializedObject ds = MessagePackSerializer.Deserialize<DeserializedObject>(z);

So i wonder how can i register my class ?

like image 933
cUser Avatar asked Sep 06 '25 03:09

cUser


1 Answers

What i did was to generate resolver and formatter using this:

1. mpc.exe -i "..\src\Sandbox.Shared.csproj" -o "MessagePackGenerated.cs" -m
2. restart unity +  vscode
3.
    var resolver = MessagePack.Resolvers.CompositeResolver.Create(
                    NameOfGeneratedNamespace.Resolvers.NameOfResolver.Instance);
    var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);

    DeserializedObject ds = MessagePackSerializer.Deserialize<DeserializedObject>(z,options);
like image 53
cUser Avatar answered Sep 07 '25 20:09

cUser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!