Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MemoryPack.MemoryPackSerializationException : <class> is not registered in this provider

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

like image 564
yawork Avatar asked Jun 06 '26 21:06

yawork


1 Answers

Update : Problem solved by using "MemoryPack" package and not "MemoryPack.Core"

Solution by package author

like image 170
yawork Avatar answered Jun 08 '26 10:06

yawork



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!