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

  • Home
  • SEARCH
  • 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 766949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:07:53+00:00 2026-05-14T17:07:53+00:00

I’m serializing an object and storing the serialized value in db and getting the

  • 0

I’m serializing an object and storing the serialized value in db and getting the deserialization to work fine as well after getting values from db.

But problem occurs if the existing object is modified and a new property is added in the class. Then while deserializing it looks for that property in serialized text and upon not finding it there, I get the following error

System.Runtime.Serialization.SerializationException: Member ‘temp’ was not found.

Is there any way I can know if new property was not there while serialization and can skip that? I’m using custom 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-14T17:07:53+00:00Added an answer on May 14, 2026 at 5:07 pm

    This is a common problem when de/re hydrating instances and changing the underlying type at the same time.

    What you can do in these kind of situations is to write the equivalent of a header out along with the property information which can be used upon deserialization so that you can know which fields were actually serialized in the first place. The way that you ‘tag’ each field is entirely up to you, here I’m going to do it the most naive way just for demonstration purposes:

    public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
    {
      info.AddValue("_Fields", 2);
      info.AddValue("FieldA", FieldA);
      info.AddValue("FieldB", FieldB);
    }
    
    protected MyObject(SerializationInfo info, StreamingContext context)
    {
      int fields = 0; 
      try{
        fields = info.GetInt32("_Fields");
      }      
      catch(Exception)
      {
         /* min known version kicks in instead, i.e. 
            before you added this field-tracking value */
      }
    
      if(fields!=0)
      {
        //if using an integer tracking field, you could also consider using
        //bit flags - changing these tests to (fields & [fieldFlag]) == [fieldFlag]
        //which would allow you to accommodate multiple combinations of fields more easily.
        if(fields == 1)
          FieldA = info.GetInt32("FieldA");
        if(fields == 2)
          FieldB = info.GetInt32("FieldB");
      }
    }
    

    As the code suggests, when you roll-out this change, you should have a good knowledge of what the current mimum level of detail you can expect from the object data in your data stores, so you can still deserialize all the stuff that doesn’t perform this.

    You could take this a lot further and use strings to track the data that’s present, making each string equal to the name of the field that is stored, and then employ some reflection-based solution that will automatically fill the fields. That’s likely to be ugly code though (or, at least, I don’t have enough time right now to provide an example!).

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

Sidebar

Ask A Question

Stats

  • Questions 386k
  • Answers 386k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can think of an interface as a "contract". You… May 14, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer Here's a quick sample to help you on your way:… May 14, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer You can scroll horizontally to a position using jQuery's .scrollLeft()… May 14, 2026 at 11:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.