GeezerVison is showing github.com — [v3] Issue with AOT Platforms - DynamicAssembly · Issue #1906 · MessagePack-CSharp/MessagePack-CSharp
[v3] Issue with AOT Platforms - DynamicAssembly #1906
Description
Unfortunately on Unity 6, (nuget MessagePack 3.0.129-beta) with following MessagePack initialization code:
StaticCompositeResolver.Instance.Register(new[]
{
MasterMemoryResolver.Instance,
UlidMessagePackResolver.Instance,
StandardResolver.Instance
});
During Runtime on Android (IL2CPP build) there is an error with DynamicAssembly:
Error Unity PlatformNotSupportedException: Operation is not supported on this platform.
Error Unity at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in <00000000000000000000000000000000>:0
Error Unity at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x00000] in <00000000000000000000000000000000>:0
Error Unity at MessagePack.Resolvers.DynamicObjectResolver+<>c.<.cctor>b__4_0 () [0x00000] in <00000000000000000000000000000000>:0
Error Unity at ListWithEvents`1[T]..ctor () [0x00000] in ./Library/PackageCache/com.unity.addressables/Runtime/ResourceManager/Util/ListWithEvents.cs:8
Error Unity at System.Lazy`1[T].ExecutionAndPublication (System.LazyHelper executionAndPublication, System.Boolean useDefaultConstructor) [0x00000] in <00000000000000000000000000000000>:0
It is somewhat connected with the defines - previously defining MESSAGEPACK_FORCE_AOT didn't result in any change - it was still trying to use DynamicAssembly on platforms that doesn't support it.
Source: #1888 (comment)
Activity
evorowy-jk commented on Jul 29, 2024
Is there any workaround that I can use to safely use message pack on AOT?
For the following class if I omit DynamicObjectResolver.Instance
[MessagePackObject(true)]
public class PlayerData : IPlayerData
{
public SemVersion Version { get; set; } = new();
public int A;
public List<A> Items { get; set; } = new();
}
It is unable to find Formatter for List (A has MessagePackObjectAttribute too).
Is there some other way that I should take when working with MessagePack?
neuecc commented on Jul 30, 2024
The code generated by the Source Generator is applied first, so it should not normally reach the DynamicObjectResolver.
Can you check the code generated by the Source Generator?
AArnott commented on Sep 25, 2024
Closing due to non-response from OP. Also, we've made several fixes in this area lately. Ideally the OP can test on the latest from our develop branch.
Metadata
Metadata
Development
No branches or pull requestsIssue actions