【发布时间】:2014-10-22 22:18:56
【问题描述】:
我正在开发基于 GPS 服务的应用程序,我必须持续跟踪用户的位置,例如 HERE 地图,我正在使用以下代码:
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.MovementThreshold = 20; //Doesn't matter the value I put here, it won't work
geolocator.PositionChanged += geolocator_PositionChanged;
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
if(args.Position != null)
{
myPosition = args.Position.Coordinate.ToGeoCoordinate();
UpDateData();
}
});
}
问题是:我遇到了 System.Reflection.TargetInvocationException
你有解决这类问题的办法吗?
【问题讨论】:
-
确保
ID_CAP_LOCATION在 Capabilities 中被选中。如果这不能解决您的问题,我会假设它来自UpDateData(),请将其注释掉。 -
ID_CAP_LOCATION 是我开始开发部分时检查的第一件事
-
在 UpDateData() 函数中,我只根据我当前的位置将图钉放在地图控件中
-
如果你把它注释掉会发生什么?
标签: c# windows-phone-8 location system.reflection