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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:10:35+00:00 2026-05-13T14:10:35+00:00

[Serializable] public class ModelResource:ISerializable { public Int64 Ore { get; private set; } public

  • 0
[Serializable]
public class ModelResource:ISerializable
{
   public Int64 Ore { get; private set; }
   public Int64 Crystal { get; private set; }
   public Int64 Hydrogen { get; private set; }
   //needs to be ignored
   public Int64 Total { get { return Ore + Hydrogen + Crystal; } }
   public string ResourceType { get; private set; }
   public Int64 HerculesNeeded { get { return Total / 25000; } }
   public Int64 AtlasNeeded { get { return Total / 5000; } }

   public bool IsPlanet { get { return ResourceType == "Planet"; } }
   //causes serializer to stackoverflow
   public ModelResource MakeChild {get{return new ModelResource(Ore/2,Crystal/2,Hydrogen/2);}}


    public string ToJson()
    {
        var jss = new System.Web.Script.Serialization.JavaScriptSerializer(new SimpleTypeResolver());
        return jss.Serialize(this); //throws recursion limit exceed exception
    }
    #region ISerializable Members

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("Ore", Ore);
        info.AddValue("Crystal", Crystal);
        info.AddValue("Hydrogen", Hydrogen);
        info.AddValue("ResourceType", ResourceType);
    }
    private ModelResource(SerializationInfo si, StreamingContext context)
    {
        Ore = si.GetInt64("Ore");
        Crystal = si.GetInt64("Crystal");
        Hydrogen = si.GetInt64("Hydrogen");
        ResourceType = si.GetString("ResourceType");
    }


    #endregion
}
  • 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-13T14:10:35+00:00Added an answer on May 13, 2026 at 2:10 pm

    Normally I would suggest telling it to ignore parent properties (which create cycles) – in this case by adding [ScriptIgnore] – but I can’t see anything other than basic members – is this class by itself enough to cause the error?

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

Sidebar

Related Questions

Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
I'm de/serializing an object like so: public class myClass : ISerializable { public List<OType>
In C#, consider we have a generic class and a concrete class [Serializable] public
I have: class MyClass extends MyClass2 implements Serializable { //... } In MyClass2 is
If something inherits from a Serializable class, is the child class still Serializable?
Trying to write my first generic class in C#: public class HighScoreList<ScoreType> where ScoreType
I have a Serializable object which is supposed to hold a java.awt.Image as its
I know that Serialization (Serializable) is not available in the Micro Edition of Java.
GWT's serializer has limited java.io.Serializable support, but for security reasons there is a whitelist
Is it possible to pass objects (serializable classes or other ways) to a Silverlight

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.