Serialization Error

Topics: Windows Forms
Dec 4, 2011 at 2:33 PM


First of all Thanks for great control.


i have issues about serializing the overlays, i try SerializeOverlays with no luck, saying that Pen is not marked as Serializable.

also try to modify the code not saving the Pen and Brush Property but after that another error occur ( The constructor to deserialize an object of type 'GMap.NET.WindowsForms.Markers.GMarkerGoogle' was not found. )


am i doing smth wrong?


the code is:

public T DeepClone<T>(T obj)       


using (var ms = new System.IO.MemoryStream())           


var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();               

formatter.Serialize(ms, obj);

ms.Position = 0;

return (T)formatter.Deserialize(ms);           





GMapOverlay overlay = DeepClone<GMapOverlay>(<some overlay>);


Dec 4, 2011 at 3:43 PM

i've never used serialization, don't know

Dec 4, 2011 at 5:08 PM

p.s. found the problem, default markers wasn't implemented correctly:

"If you inherit from a class which is implementing ISerializable (like Hashtable) and you want that your class to be serializable also, you must implement the methods from ISerializable interface:

- the serialization constructor, used at deserialization; which is a must; because you didn't implement it you have that error

protected CSDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { }

- the serialization method GetObjectData used at serialization, which you need to implement if you have additional data to serialize."

Dec 4, 2011 at 9:24 PM

check it now, should be ok

Dec 5, 2011 at 3:43 PM



Thanks for detailed explanation.

still has errors on Pen in GMapPolygon, anyway decide to impement my own class which collect data i need and be serialized.


Best Regards.

Dec 5, 2011 at 5:49 PM

fixed now ;}

Dec 5, 2011 at 7:59 PM