简体   繁体   English

GeoCoordinate System.FormatException

[英]GeoCoordinate System.FormatException

I have a viewmodel which contains a System.Device.Location.GeoCoordinate property which is marked as [DataMember] like so: 我有一个包含System.Device.Location.GeoCoordinate属性的视图模型,该属性被标记为[DataMember],如下所示:

[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: 我有一个此viewmodel的集合,对于集合的每个项目,我都会得到:

A first chance exception of type 'System.FormatException' occurred in mscorlib.dll mscorlib.dll中发生类型为'System.FormatException'的第一次机会异常

The interesting part is that this only occurs when I am navigating back, but somewhere before OnNavigatedTo event fires. 有趣的是,这仅在我向后导航时发生,而在OnNavigatedTo事件触发之前的某处。

Is this a known issue? 这是一个已知的问题? how can I fix it? 我该如何解决?

Are you sure GeoCoordinate is serializable by the DataContractSerializer ? 您确定GeoCoordinate可通过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. 尝试构建自定义的GeoCoordinate类型:编写一个具有两个双纬度/经度属性的简单类,一个BuildFromGeoCoordinate()ToGeoCoordinate()方法,以从/ GeoCoordinateGeoCoordinate ,并检查是否仍然发生错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM