ThinkGeo.com    |     Documentation    |     Premium Support

MapView.SaveState no default accessor

Doing some testing and I am trying the byte[] state = MapView.SaveState function. When I run it I get.

System.InvalidOperationException: 'You must implement a default accessor on System.Collections.Generic.Stack

Am I missing something?

Hi Chris,

You haven’t missed anything; the issue is actually with the MapView.SaveState() method.

SaveState() and LoadState() used BinaryFormatter for serialization and deserialization, which was OK at first. However, Microsoft has moved away from BinaryFormatter due to security concerns. As a result, we don’t really recommend using these methods anymore, and they haven’t been updated to support new types, which is why you’re running into this problem.

Right now, we don’t have a great alternative to offer. Ideally, we need to phase out BinaryFormatter and find a better solution, but we haven’t found the right one yet or had the chance to implement it.

We’re going to mark the method as obsolete to steer people away from using it, and we’ll also bump up the priority to find an alternative solution sooner rather than later.

Sorry for the hassle this has caused.

Thanks,
Ben

Thanks for the heads up!

Hi Chris,

Also, just let you know you can save/restore state by implementing your own custom serialization. Here is a post on the same topic, please have a look see if that helps.

GridFeatureLayer Serializes cell values - ThinkGeo UI for Desktop / WinForms - ThinkGeo Discussion Forums

Thanks,
Ben