Getting location in Windows 8 desktop apps

怎甘沉沦 提交于 2019-11-30 22:04:35
Alex Filipovici

To fix your error you have to reference to the link that Bart gave in one of the question's comments.

You might need to add a reference to System.Runtime.WindowsRuntime.dll as well if you are using mapped types like Windows Runtime event handlers:

...

That assembly resides in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5

I recently found a "solution" for a similar question: C# desktop application doesn't share my physical location. Maybe you might be interested by my approach: https://stackoverflow.com/a/14645837/674700.

It's more like a workaround and it's not targeting Windows 8, but it works in the end.

Shobhan Taparia

alex's solution works! add that reference and geolocation api starts working like a charm! so do async methods for other sensors!

here is a function i just got working using it.

async public void UseGeoLocation()
{
    Geolocator _GeoLocator = new Geolocator();
    Geoposition _GeoPosition = 
        await _GeoLocator.GetGeopositionAsync();

    Clipboard.Clear();
    Clipboard.SetText("latitude," + 
        _GeoPosition.Coordinate.Latitude.ToString() + 
        "," + "longitude," + _GeoPosition.Coordinate.Longitude.ToString() + 
        "," + "heading," + _GeoPosition.Coordinate.Heading.ToString() +
        "," + "speed," + _GeoPosition.Coordinate.Speed.ToString());

    Application.Exit();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!