ThinkGeo.com    |     Documentation    |     Premium Support

Serialize WPFMap control

 


Hi,
We are trying to serialize the WPFMap control,
 
we are getting the following errors  and we  will be grateful if you take a look on it and help us to solve them.
 
First I tried to Serialized the ThinkGeo.MapSuite.DesktopEdition.WpfMap directly using the below code(I tested soap formatter too):
            ThinkGeo.MapSuite.DesktopEdition.WpfMap MyWPF = new ThinkGeo.MapSuite.DesktopEdition.WpfMap();
            FileStream fs = new FileStream(@"c:\\SerializedDate3.Data", FileMode.Create);
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(fs, MyWPF);
            fs.Close();
 
But I received the below error:
Type 'System.Windows.Controls.Canvas' in Assembly 'PresentationFramework, Version=X.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.
 
Then I tried to sterilize the properties of the control:
            FileStream fs = new FileStream(@"c:\\SerializedDate2.Data", FileMode.Create);            
            BinaryFormatter bf = new BinaryFormatter();            
            bf.Serialize(fs, wpfMap1.Overlays);           
            fs.Close();
 
But I received another error:
Type 'System.IO.FileStream' in Assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Now I’m trying to create my classes based on the ThinkGeo.MapSuite.DesktopEdition.WpfMap properties and the serialized/desterilized them, but I’m not sure this way will work for all properties and it will not make unpredicted problems.

Any ideas on how to solve this would be great


 


Thanks



I should add something to Richard’s post. 
  
 in our application users can add different layer to the map ,edit the layer’s properties and then save the map, so we need to serialized the whole map control with its properties and then next time when user open the project , we should desterilized the map and show it exactly like the save time. 
  
  
 Regards

Richard & Ben, 
  
 Thanks for your post and questions. 
  
 I think the serialization and de-serialization for the map control is definitely very important, while it is not fully implemented yet, it is still on our project schedule.  
  
  
 Now, we are still working on the serialization and de-serialization of the classes in Core which is the base of the Map Control. Hopefully we can fully support the serialization and de-serialization of the Map control both in binary format and XML format. 
  
 Sorry for the inconvenience now. 
  
 Thanks. 
  
 Yale