Skip to content

Quickstart example is not working #471

Closed

Description

@DataGreed

The example in quickstart generates a runtime error:

FormatterNotRegisteredException: MyClass is not registered in this resolver. resolver:StandardResolver

Activity

  1. nogic1008 commented on Jul 3, 2019

    @nogic1008

    Does MyClass have MessagePackObject attribute?
    It is required for use StandardResolver.

  2. brookman commented on Jul 3, 2019

    @brookman

    @DataGreed Are you using Unity?
    Sadly the library seems to be broken with the API setting ".Net Standard 2.0". Unfortunately this is now the default setting.
    Workaround: You can get it running by changing the option to ".NET 4.x" (under "Player Settings" -> "Other Settings" -> "Api Compatibility Level".

  3. DataGreed commented on Jul 3, 2019

    @DataGreed
    Author

    After struggling with this library for several hours I've switched to https://github.com/msgpack/msgpack-cli which worked for me out-of-the-box.

    Not sure if I will return to trying this one unless serialization becomes a bottleneck.

    @brookman yes, I am using Unity. Thank you for the workaround! If I'll have some free time I'll probably try it.

  4. DataGreed commented on Jul 3, 2019

    @DataGreed
    Author

    @nogic1008 yes it does. I've implemented everything like the readme suggested.

  5. odysoftware commented on Jul 4, 2019

    @odysoftware

    I am using Unity with .NET Standard 2.0 and this library (v1.7.3.5) without any issues,

  6. brookman commented on Jul 5, 2019

    @brookman

    @odysoftware Which Unity version and platform do you use. (I have 2019.1.5f1 and target Android)

  7. odysoftware commented on Jul 5, 2019

    @odysoftware

    I have been using this library from 2018.1 till latest version 2019.1

    So currently I am on 2019.1.8.f1 and targeting iOS, Android and MacOS. I am using IL2CPP mode and .NET Standard 2.0. And for MessagePack I have the v.1.7.3.5 unity package installed. I don't get any errors and afaik the v.1.7.3.5 was specially made for .net standard 2.0 compatibility.

  8. brookman commented on Jul 10, 2019

    @brookman

    @odysoftware are you using code generation (mpc.exe)? If yes, which version? I have spent a few hours but could not get it running...

  9. odysoftware commented on Jul 10, 2019

    @odysoftware

    Yeah getting mpc.exe working on mac was sometimes a bit of a pain. But since using a .NET Core Server Project it was working fine - not sure anymore if I had to use something special - but I was thinking it just worked once I switched to .NET Core and latest Messagepack from neuecc via nuget?

  10. SradnickDev commented on Nov 1, 2019

    @SradnickDev

    Encountering the same issue.
    MessagePack.Unity.1.7.3.5.unitypackage
    Unity 2019.2.8f1

  11. AArnott commented on Dec 6, 2019

    @AArnott
    Collaborator

    This issue was filed against a 1.x version of the library. A lot of changes have been made to this area in 2.0 and I suspect this is fixed or no longer applies. Please retry your scenario on 2.0 and comment here if you think the issue should be re-opened.

  12. MoctezumaDev commented on Jan 20, 2020

    @MoctezumaDev

    I think I have this issue in IL2CPP and .NET 4.x Unity 2019.2.16f

  13. AArnott commented on Jan 20, 2020

    @AArnott
    Collaborator

    @leonidaX The original issue of "MyClass is not registered in this resolver" is simply a failure to configure the serializer per the README instructions. Please review those and if there's an issue open a new issue with details including the messagepack version you're using.

  14. NoxMortem commented on Apr 30, 2020

    @NoxMortem

    @AArnott still I believe the quickstart be formulated s.t. it works out of the box and it does on .NET 4 Framework and fails as @DataGreed posted if you switch to .NET 2.0 as you can see in this example project by switching the framework and simply entering play mode (platform: PC)
    ThisTookMe10Minutes.zip

    Yes it does work when using mpc and a GeneratedResolver and registering it - but the quickstart example is the place to tell someone new to this repository that :)

  15. AArnott commented on May 2, 2020

    @AArnott
    Collaborator

    What do you mean by "switch to .NET 2.0"? .NET 2.0 isn't a thing. Do you mean .NET Framework 2.0 (which is so old we don't support that) or .NET Core 2.0 (which is also out of support, but 2.1 is supported).

  16. AArnott commented on May 2, 2020

    @AArnott
    Collaborator

    It sounds like your questions are Unity and/or mpc-specific, so I can't comment much as I don't know much about either -- @neuecc is the expert there.

  17. reopened this on May 2, 2020
  18. neuecc commented on May 2, 2020

    @neuecc
    Member

    Unity's platform matrix is...

    • .NET Standard 2.0
    • .NET Framework 4.x

    and

    • Mono 2.x
    • IL2CPP

    and

    • Windows
    • Mac
    • iOS
    • WebGL
    • etc...

    Code generation and Register are required except for .NET 4.x + mono.
    If you have title problems with IL2CPP, please generate code.

  19. NoxMortem commented on May 3, 2020

    @NoxMortem

    @neuecc Thanks. That is actually super helpful and while now clear it might be good to put that into the first sentence of the Unity Code Generation section in the readme :)

    Is there anything beside Reflect.Emit that is missing in .NET Standard 2.0 for MessagePack to get rid of mpc?

    I always thought Reflect.Emit would be available in .net Standard 2.0 but just realized/learned that this is not the case:

    @DataGreed can this ticket be closed?

    @AArnott yes that was a Unity specific example related to the possibility to switch the scripting backend used there and show casing how the quick start breaks (as expected according to the answer of @neuecc )

  20. AArnott commented on May 3, 2020

    @AArnott
    Collaborator

    Reflection.Emit is available in netstandard2.0. In fact it was available in netstandard1.6, as you can see with here: https://apisof.net/catalog/System.Reflection.Emit.TypeBuilder. It's just that it requires one extra package reference, but it works fine on .NET Framework and .NET Core 2.x when doing so.

    MessagePack's netstandard2.0 build has all the Ref.Emit code in it.

    But in Unity when compiling MessagePack from source (which is the only way we support it), the relevant defines is not NETSTANDARD2_0 but rather NET_STANDARD_2_0 (along with some others). So Ref.Emit is left out of some Unity compilations, I believe. Although there have been multiple attempts to get it more thoroughly removed from platforms that don't support it so that things tend to work more. #890 is one currently active PR, that I and @neuecc need to review.

  21. github-actions commented on Aug 2, 2020

    @github-actions
    Contributor

    This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

  22. bitinn commented on Jun 13, 2021

    @bitinn

    Not to relitigate this issue, but I would like to see Neuecc's comment above in Readme,

    The readme currently has a wall of text on Unity usage, but doesn't actually explain you have to code gen manually if you use .net standard 2.0; it really should just say, no, unless you use .net 4.x + mono, you have to code gen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions