Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary serialization in .NET Core

I am working on a .NET Core project and I am trying to parse my List<T> to byte[]. Using the .NET Framework, we could have achieved the same by using BinaryFormatter, but at the time of writing this question it looks like Microsoft does not yet support it in .NET Core and no upcoming releases seem to do that.

Can anybody tell how to perform this serialization in .NET Core? Also, is binary serialization platform-dependent, and for such reason been deprecated in .NET Core?

like image 412
Rohit Avatar asked Mar 01 '17 08:03

Rohit


2 Answers

You can use Binaron.Serializer - https://github.com/zachsaw/Binaron.Serializer There's no need to decorate your class with any attributes.

Disclaimer: I'm the author of Binaron.Serializer.

like image 122
Zach Saw Avatar answered Oct 01 '22 14:10

Zach Saw


You can use MessagePack. The package is chosen as Package of the week in .Net blog.

Nuget command:

Install-Package MessagePack

You can also take a look into their source code and see how it is implemented in .net core.

like image 29
Aboo Avatar answered Oct 01 '22 14:10

Aboo