I have a viewmodel which contains a System.Device.Location.GeoCoordinate property which is marked as [DataMember] like so:
[DataMember]
public GeoCoordinate Location
{
get
{
return _location;
}
set
{
if (_location != value)
{
_location = value;
NotifyPropertyChanged("Location");
}
}
}
I have a collection of a this viewmodel, and for every item of the collection I am getting:
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
The interesting part is that this only occurs when I am navigating back, but somewhere before OnNavigatedTo event fires.
Is this a known issue? how can I fix it?
Are you sure GeoCoordinate
is serializable by the DataContractSerializer
?
Try to build a custom GeoCoordinate
type: write a simple class with two double latitude/longitude properties, a BuildFromGeoCoordinate()
and a ToGeoCoordinate()
method to convert from/to GeoCoordinate
, and check if the error still happens.