ThinkGeo.com    |     Documentation    |     Premium Support

Unable to deserialize GdiPlusRasterLayers from a previous version

We have used version 4.5 for a long time now in our product. One of the things we do is to use a BinaryFormatter to serialize our View class. One of the members of the View class is a List of GdiPlusRasterLayers (although in practice there is either 0 or 1 members of the list)

public class View : ISerializable
{
    public Guid ViewId { get; set; }
    public List<GdiPlusRasterLayer> Rasters { get; set; }
    public string ViewName { get; set; }
    etc etc etc
}

This works well except once I installed version 9, this Rasters member is no longer de-serializing correctly, which would break all of our customers’ views if we were to switch to version 9. I assume the format changed somewhere along the line. Any idea how I can deserialize a list of version 4.5 GDIRasterPlusLayers in version 9?

Dave

Hi David,

Do you meant, you saved many serialized GdiPlusRasterLayers by our 4.5 version, but they cannot be de-serializing correct by 9.0, right?

I did a quickly compare, the GdiPlusRasterLayer don’t have big changes, so you should want to follow the steps as below to build new 9.0 serialized binary data:

  1. Use 4.5 dll to de-serialize the saved GdiPlusRasterLayer
  2. Read mainly property from GdiPlusRasterLayer and GdiPlusRasterSource
  3. Save the properties into a text file or xml file
  4. Use 9.0 dll to build another application, read the text file and xml file then build a new 9.0 GdiPlusRasterLayer
  5. Serialize the 9.0 GdiPlusRasterLayer into binary and replace original ones

When you handle this, I think maybe you will met some problem like imageExtent cannot be read from 4.5 GdiPlusRasterLayer. If you hadn’t use the constructor which contains parameters: string worldfilePathFilename or RectangleShape imageExtent, you can just ignore this problem. Orelse, I think you should want to try to read the private property value by reflect in memory.

Wish that’s helpful.

Regards,

Don