0

I would like to change the name of a class that is being persisted through serialization/deserialization (using a binary formatter). If I simply refactor the name to another name, the deserialization of the file won't load (nor did I expect this).

Is there a way to tell the deserializer to load the class under another class-name, so that I can change the name of the class but still keep the old (and big!) file? Or can I serialize using another class name?

Does the question make sense?

Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
Zoidboom
  • 11
  • 2
  • Does this help? https://stackoverflow.com/questions/30021070 – D Stanley Dec 18 '20 at 16:46
  • Or maybe this? https://stackoverflow.com/questions/12737602 – D Stanley Dec 18 '20 at 16:48
  • 1
    If you're using `BinaryFormatter`: you're going to have a *really* bad time of it, ultimately. Solving this **may be the wrong thing**, especially since you include the [tag:.net-core] tag. Important: `BinaryFormatter` is essentially dead; it *barely* works in .NET Core, less so in .NET 5. What limited options there are to configure things in `BinaryFormatter` (see: `SerializationBinder`): they're only a tiny tiny holding gap in a *much bigger problem*. Honestly, I'd use **any other serializer**. I could make suggestions (I'm hugely biased in this space), but... – Marc Gravell Dec 18 '20 at 16:50
  • 1
    (oh, also: don't use `NetDataContractSerializer`; exact same problems; and `BinaryFormatter` is also a huge security problem, in case you didn't know - https://blog.marcgravell.com/2020/03/why-do-i-rag-on-binaryformatter.html) – Marc Gravell Dec 18 '20 at 16:52

0 Answers0