You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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".
Reacted by Alexey, Nogic, Gage Lucas, Andrei-Ștefan Trifu, Genix_NK, Adam Preble, Martin Král, dzmitry-lahoda and Piotr Kosek
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.
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?
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.
@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.
@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 :)
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).
@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:
@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 )
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 notNETSTANDARD2_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.
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.
Activity
nogic1008 commentedon Jul 3, 2019
Does
MyClasshaveMessagePackObjectattribute?It is required for use
StandardResolver.brookman commentedon Jul 3, 2019
@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".
DataGreed commentedon Jul 3, 2019
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.
DataGreed commentedon Jul 3, 2019
@nogic1008 yes it does. I've implemented everything like the readme suggested.
odysoftware commentedon Jul 4, 2019
I am using Unity with .NET Standard 2.0 and this library (v1.7.3.5) without any issues,
brookman commentedon Jul 5, 2019
@odysoftware Which Unity version and platform do you use. (I have 2019.1.5f1 and target Android)
odysoftware commentedon Jul 5, 2019
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.
brookman commentedon Jul 10, 2019
@odysoftware are you using code generation (mpc.exe)? If yes, which version? I have spent a few hours but could not get it running...
odysoftware commentedon Jul 10, 2019
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?
SradnickDev commentedon Nov 1, 2019
Encountering the same issue.
MessagePack.Unity.1.7.3.5.unitypackage
Unity 2019.2.8f1
AArnott commentedon Dec 6, 2019
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.
MoctezumaDev commentedon Jan 20, 2020
I think I have this issue in IL2CPP and .NET 4.x Unity 2019.2.16f
AArnott commentedon Jan 20, 2020
@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.
NoxMortem commentedon Apr 30, 2020
@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 :)
AArnott commentedon May 2, 2020
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).
AArnott commentedon May 2, 2020
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.
neuecc commentedon May 2, 2020
Unity's platform matrix is...
and
and
Code generation and Register are required except for .NET 4.x + mono.
If you have title problems with IL2CPP, please generate code.
NoxMortem commentedon May 3, 2020
@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:
but it will be available in .NET Core 3 (not available in Unity yet and there is no ETA as far as I know)
@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 )
AArnott commentedon May 3, 2020
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_0but ratherNET_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.github-actions commentedon Aug 2, 2020
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.
bitinn commentedon Jun 13, 2021
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.