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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:18:32+00:00 2026-06-16T09:18:32+00:00

I have a class X which implements ISerializable #region ISerializable Members /// <summary> ///

  • 0

I have a class X which implements ISerializable

#region ISerializable Members

    /// <summary>
    /// Sets up for deserialization
    /// </summary>
    /// <param name="info"></param>
    /// <param name="context"></param>
    private X(SerializationInfo info, StreamingContext context)
    {
        this.Key = info.GetString("Key");
        this.Title = info.GetString("Title");
        this.Count = info.GetInt32("Count");

        originalDataSource = new ObservableDataSource<IDataType>((IDataType[])info.GetValue("DataSource", typeof(IDataType[])));

        this.A = (Color)ColorConverter.ConvertFromString(info.GetString("A"));
        this.B = Utilities.GetDashStyleFromString(info.GetString("B"));
        this.C = info.GetDouble("C");
        this.D = (Color)ColorConverter.ConvertFromString(info.GetString("D"));
        this.E = (Shape)Enum.Parse(typeof(Shape), info.GetString("E"));
        this.F = info.GetInt32("F");
        this.G = info.GetInt32("G");
        this.H = info.GetInt32("H");
        this.I = info.GetBoolean("I");
    }

    /// <summary>
    /// Sets up for serialization
    /// </summary>
    /// <param name="info"></param>
    /// <param name="context"></param>
    [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("Key", this.Key);
        info.AddValue("Title", this.Title);
        info.AddValue("Count", this.Count);

        info.AddValue("DataSource", this.originalDataSource.Collection.ToArray<IDataType>());

        info.AddValue("A", this.A.ToString());
        info.AddValue("B", this.B.ToString());
        info.AddValue("C", this.C);
        info.AddValue("D", this.D.ToString());
        info.AddValue("E", this.E);
        info.AddValue("F", this.F);

        info.AddValue("G", this.G);
        info.AddValue("H", this.H);
        info.AddValue("I", this.I);
    }

    #endregion

I have a class Y which contains a List and an eventaggregator.

#region ISerializable Members

    /// <summary>
    /// Sets up for deserialization
    /// </summary>
    /// <param name="info"></param>
    /// <param name="context"></param>
    private Y(SerializationInfo info, StreamingContext context)
    {
        List<X> Coll = (List<X>)info.GetValue("DataSource", typeof(List<X>));

        if (_Collection == null)
            _Collection = new List<X>();

        foreach (X x in Coll)
            _Collection.Add(x);

        Count = info.GetInt32("Count");
    }

    /// <summary>
    /// Sets up for serialization
    /// </summary>
    /// <param name="info"></param>
    /// <param name="context"></param>
    [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("DataSource", _Collection);
        info.AddValue("Count", this.Count);
    }

    #endregion

I need to serialize Y in binary.

But when I deserialize Y, and check the following line, it returns a List with nulls in place of the X objects that were supposed to have been serialized.

List<X> Coll = (List<X>)info.GetValue("DataSource", typeof(List<X>));

Any idea what is wrong with this piece of code? I am unable to simply serialize with conditional serialization, the Color does not get serialized and also, the ObservableDataSource does not have Serializable attribute and I cannot modify it.

This is in .NET framework 3.5 (if that is of any use).

  • 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-06-16T09:18:33+00:00Added an answer on June 16, 2026 at 9:18 am

    The Color class is not serializable, you will have to implement your own custom serialization format for it (I usually, serialize the ARGB code instead).

    Except from that, the BinarySerializer supports collection serialization so you don’t actually need to implement your own serialization function.

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

Sidebar

Related Questions

I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,
I am new to Android and Java programming. I have a class which implements
I have a factory class, DocumentLoaderFactory , which simply returns an instance that implements
I have created a class which extends com.smartgwt.client.widgets.grid.ListGridRecord and implements com.google.gwt.user.client.rpc.IsSerializable. I am returning
I have to implement ISerializable in a derived class (to do some custom serialization/deserialization)
I have class A which has ISerializable implemented for custom serialization. Now i need
I have a class which implements Serializable. Now I extends this class and I
I have a class Data which implements Serializable interface. This class has such fields
I have a VB.NET singleton class which implements Serializable : Imports System.IO Imports System.Runtime.Serialization
I have a Category class which looks like this: @Entity @Table(name = categories) public

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.