-
-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Description
Hi, I run into some issue when using MemoryPack in my project:
Full repro code is here:
var list =new List<string>(){"123","456"};
var bytes = MemoryPack.MemoryPackSerializer.Serialize(list);when publish aot and run:
dotnet publish && ./bin/Release/net9.0/win-x64/publish/TestAot.exe
It run into error:
Unhandled exception. MemoryPack.MemoryPackSerializationException: System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] is failed in provider at creating formatter.
---> System.NotSupportedException: 'MemoryPack.Formatters.ListFormatter`1[System.String]' is missing native code or metadata. This can happen for code that is not compatible with trimming or AOT. Inspect and fix trimming and AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility
at System.Reflection.Runtime.General.TypeUnifier.WithVerifiedTypeHandle(RuntimeConstructedGenericTypeInfo, RuntimeTypeInfo[]) + 0x7e
at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.MakeGenericType(Type[]) + 0x207
at MemoryPack.MemoryPackFormatterProvider.TryCreateGenericFormatterType(Type, IDictionary`2) + 0x71
at MemoryPack.MemoryPackFormatterProvider.CreateGenericFormatter(Type, Boolean) + 0x11e
at MemoryPack.MemoryPackFormatterProvider.Cache`1..cctor() + 0x6d
--- End of inner exception stack trace ---
at MemoryPack.MemoryPackSerializationException.ThrowRegisterInProviderFailed(Type, Exception) + 0x4a
at MemoryPack.ErrorMemoryPackFormatter`1.Throw() + 0x58
at MemoryPack.MemoryPackWriter`1.WriteValue[T](T&) + 0x53
at MemoryPack.MemoryPackSerializer.Serialize[T](T&, MemoryPackSerializerOptions) + 0x342
at Program.<Main>$(String[] args) + 0x89
Is this expected? Is there any workaround?
Metadata
Metadata
Assignees
Labels
No labels