C
C#16mo ago
Jibz

❔ BinaryFormatter.Serialize(Stream, object)' is obsolete, What do I use instead?

I'm learning serialization in C# but it says binary formatters are obsolete. what should i use?
6 Replies
anita
anita16mo ago
You could use a Non Binary Seriaizer
anita
anita16mo ago
Breaking change: BinaryFormatter serialization methods are obsolete...
Learn about the .NET 5 breaking change in core .NET libraries where serialize and deserialize methods on BinaryFormatter, Formatter, and IFormatter are obsolete.
Angius
Angius16mo ago
Binary serialization is dangerous JSON would be best Or if you insist on a binary format, Protobuf
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
GrabYourPitchforks
Very specifically, BinaryFormatter serialization is dangerous. There's nothing about the "binary" part of it that makes it dangerous. It's absolutely possible to have safe binary formats (protobuf, as you suggested) - and it's absolutely possible to have dangerous text formats (NetDataContractSerializer, which is XML-based). BinaryFormatter absolutely has its problems, but it's not the "binary" part that makes it dangerous. (And yes, I know I'm responding to this well after the fact - just commenting in case people find it while searching.)
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server