I would like to test MemoryPack serializer, but obtain following exception on "MemoryPackSerializer.Serialize()" call.
Unhandled exception. MemoryPack.MemoryPackSerializationException: console_memorypack1.Person is not registered in this provider.
This is a basic .net6 console app :
Person.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MemoryPack;
namespace console_memorypack1
{
[MemoryPackable]
public partial class Person
{
public int Age { get; set; }
public string Name { get; set; }
}
}
Program.cs
// See https://aka.ms/new-console-template for more information
using console_memorypack1;
using MemoryPack;
Console.WriteLine("Hello, World!");
var v = new Person { Age = 40, Name = "John" };
var bin = MemoryPackSerializer.Serialize(v);
var val = MemoryPackSerializer.Deserialize<Person>(bin);
Read doc and googled error without success. I cannot see what is missing.
Many thanks
Update : Problem solved by using "MemoryPack" package and not "MemoryPack.Core"
Solution by package author
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With