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 117243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:18:19+00:00 2026-05-11T03:18:19+00:00

I’m de/serializing an object like so: public class myClass : ISerializable { public List<OType>

  • 0

I’m de/serializing an object like so:

public class myClass : ISerializable {   public List<OType> value;    public myClass(SerializationInfo info, StreamingContext context)   {     this.value = (List<OType>)info.GetValue('value', typeof(List<OType>));   }    void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)   {     info.AddValue('value', value, typeof(List<OType>));   } } 

The object that is in the list does have the Serializable attribute. When serializing, no errors are thrown and the list is never empty, but when deserializing all of my lists are null and I’m not sure why.

I’m marking this as answered by CQ. I was able to produce a small one off test app that does properly serialize/deserialize with the objects I’m trying to use but I still can’t seem to get it to work in my production code but I suspect it’s something small that I’m missing.

  • 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. 2026-05-11T03:18:20+00:00Added an answer on May 11, 2026 at 3:18 am

    Well the list is always empty to begin with, are you setting it via myClass.value = new List<...>(); ? Also have you saved the serialized data in both binary and xml formats so you can verify data is actually being saved?

    Just a note as well, if you are using 2.0+ you don’t have to implement ISerializable if you don’t need to control the absolute serialization, you can change value to a public property and it will serialize on it’s own.

    Edit: The following case seems to serialize and deserialize fine for me, I am posting this incase I am misunderstanding the question as a whole.

    Ignoring the nasty test code, hopefully this helps a little.

        [Serializable]     public class OType     {         public int SomeIdentifier { get; set; }         public string SomeData { get; set; }          public override string ToString()         {             return string.Format("{0}: {1}", SomeIdentifier, SomeData);         }     }      [Serializable]     public class MyClass : ISerializable     {         public List<OType> Value;          public MyClass() {  }          public MyClass(SerializationInfo info, StreamingContext context)         {             this.Value = (List<OType>)info.GetValue("value", typeof(List<OType>));         }          void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)         {             info.AddValue("value", Value, typeof(List<OType>));         }     }  ...          var x = new MyClass();          x.Value = new OType[] { new OType { SomeIdentifier = 1, SomeData = "Hello" }, new OType { SomeIdentifier = 2, SomeData = "World" } }.ToList();          var xSerialized = serialize(x);          Console.WriteLine("Serialized object is {0}bytes", xSerialized.Length);          var xDeserialized = deserialize<MyClass>(xSerialized);          Console.WriteLine("{0} {1}", xDeserialized.Value[0], xDeserialized.Value[1]); 

    Forgot the output..

    Serialized object is 754bytes

    1: Hello 2: World

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is may very well be a JVM implementation specific… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer Check if the input already has 3 words and they… May 11, 2026 at 10:40 pm
  • Editorial Team
    Editorial Team added an answer I would imagine it's wherever your OS stores temp files… May 11, 2026 at 10:40 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.