Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1101279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:00:42+00:00 2026-05-17T01:00:42+00:00

I have a C# class that is serialized to disk by the BinaryFormatter ,

  • 0

I have a C# class that is serialized to disk by the BinaryFormatter, such as this example:

// Version 3.0
[Serializable]
public class Person
{
    public string FullName;

    [OptionalField(VersionAdded=2)]
    public string NickName;
    [OptionalField(VersionAdded=2)]
    public DateTime BirthDate;

    [OptionalField(VersionAdded=3)]
    public int Weight;
}

Later, I want to refactor this class by one or more of the following
– Change its name
– Change its namespace
– Move to another assembly

As far as I can tell, the binary file can only be de-serialized if a class with the exact same name, namespace and assembly name is available.

How do I work around this?
Is it possible to map the de-serialization to a different class name, namespace and assembly without breaking Version Tolerant Serialization?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:00:43+00:00Added an answer on May 17, 2026 at 1:00 am

    After some research I realized that the BinaryFormatter does support everything I was looking for.

    A BinaryFormatter can use surrogates to

    1. Provides the ability to serialize a type that was not originally designed to be serialized.
    2. Provides a way to map one version of a type to another version of another type.

    One can also map deserialization from type A to type B (different class name, namespace and/or assembly name) by using SerializationBinder.

    As far as I can tell, this makes it possible to refactor classes that are serialized and to maintain backwards compatibility when making breaking changes that is not supported by versioning alone.

    Reference: http://www.diranieh.com/NETSerialization/BinarySerialization.htm

    Edit: On a side note, refactoring fields (name or type) is still a pain, as discussed in Renaming fields then deserializing in C#. I am currently looking into protobuf-net to better solve this in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class that looks like this: class A { public: class variables_map vm
Lets say i have a class [Serializable()] public class Car { public string model;
I have a class that I have serialized to disk on local users machines.
I have a class that I want to be serializable but contains a public
We have some code that looks like this: class Serializer { public: template<class Type>
I have a data class that is serialized with the DataContractSerializer . The class
I have a class that I serialize/deserialize using XmlSerializer . This class contains a
I have a class that can be serialized. One of the properties is an
I have a Java class that is stored in an HttpSession object that's serialized
I have a class that implements Serializable , it's part of a bigger mesh

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.