Why is SortedDictionary not serialized?

public static SortedDictionary<int, Tower> DICT_TOWER = new SortedDictionary<int, Tower>(); 

SerializationException: Type System.Collections.Generic.RBTree is not marked as Serializable. System.Runtime.Serialization.Formatters.Binary.BinaryCommon.CheckSerializable (System.Type type, ISurrogateSelector selector, StreamingContext context) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.Serial. Formatters.Binary / BinaryCommon.cs: 119) System

So it is serialized without errors:

  public static Dictionary<int, Tower> DICT_TOWER = new Dictionary<int, Tower>(); 

The dictionary is inside the data

 BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Binder = new ClassBinder();//Здесь мы обучаем сериализатор работать с нашим классом MemoryStream streamReader = new MemoryStream(); bformatter.Serialize(streamReader, data);//Cериализуем 
  • Most likely you have an attribute in the class that is not serialized, for example event .... accordingly, it should be marked as non-serializable ... something like [field:NonSerializedAttribute()] public event EventHandler BrazierCuttoffChanged; - Alexey Shimansky
  • Which class attribute? The Tower class is normally serialized inside Dictionary <int, Tower> - codename0082016
  • We must look at the whole class in which this field. and how are you all doing ...., i.e. as in the same data and what you shove ...... but the problem is not in SortedDictionary - Alexey Shimansky
  • Maybe the problem is only on Mono? - VladD
  • 3
    @VladD exactly on Mono, lists.ximian.com/pipermail/mono-bugs/2008-August/078574.html . It seems that they did not fix it in 8 (!) Years. - rdorn

0