Home > Mobile >  Deserialize array that was Serialized with BinaryFormatter, without using BinaryFormatter to deseria
Deserialize array that was Serialized with BinaryFormatter, without using BinaryFormatter to deseria

Time:04-22

BinaryFormatter is now obsolete for security reasons. Unfortunately, there is a ton of old legacy records that were serialized to array using the BinaryFormatter. Is there a way to deserialize those records in a new app WITHOUT using BinaryFormatter or are we stuck doing a massive overhaul to pull records, deserialize and reserialize in a different format?

Edit: I am trying to convert the byte[] into an object. The only other way I know how to do that is with Deseralize from System.Text.Json. But BinaryFormatter doesn't use encode, it uses a BinaryData type. System.Text.Json expects encode, utf8 not to mention it expects json.

Edit: Getting closer. Part of the issue is the format is in MS-NRBF when you use BinaryFormatter. There is a nuget that helps you read the format. (https://github.com/bbowyersmyth/BinaryFormatDataStructure) You still have to manually reflect and manage the object assignment, but at least this lets you read the MS-NRBF format.

CodePudding user response:

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter?

Can you use System.IO.BinaryReader?

CodePudding user response:

I would back up the data and would do a one-time conversion of all data to a new format. Easy code and fewer chances to screw up things.

  • Related