I wanted to minimize changes to code in my save-file function by only making changes in the class that will be saved. Instead of making a "save-file" function in the class, I decided to try making it serializable but I receive a runtime error saying "PublicKeyToken=null" not marked as serializable.

Here's the class I want to make serializable:

[Serializable()]
    public class Marker// : ISerializable     
    {
        public Marker()
        {
            commonId++;
            id = commonId;
        }
        public AAShape shape;
        public int nextLinkId;
        public int id;
        static int commonId = 0;

        
        //public void GetObjectData(SerializationInfo info, StreamingContext context)
        //{
        //    if (info == null)
        //        throw new System.ArgumentException("info == null");
        //    info.AddValue("Shape", shape);
        //    info.AddValue("nextLinkId", nextLinkId);
        //    info.AddValue("id", id);
        //    info.AddValue("commonId", commonId);
        //}
    }

also note that AAShape is a different class that I will also make serializable.

Member Avatar for stbuchok

You will need to make sure that all types used in the class are serializeable, this means that you will need to make AAShape serializeable now and not later.

Do I just need to add

[Serializable]

above the class or what?

Please post some code for the class AAShape.

AAShape is an abstract base class from which 3 classes are derived.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.