Geolocation get location async cannot be awaited

笑着哭i 提交于 2019-12-12 02:34:17

问题


I am creating a c# form application(It's important to note that it's not a mobile app cause I think that is part of the issue). I am trying to use the Windows devices geolocation libraries and I am running into the issue that the code given on the microsoft website doesn't work.

            GeolocationAccessStatus accessstatus = await Geolocator.RequestAccessAsync();

This code should work fine but I get the error "IAsyncOperation does not contain a method for getawaiter and no extension method accepting a first argument of IAsyncOperation" What is causing this. I know it says that you need using system in the declarations but I have that so it can't be that. What is causing the issue? Note the method it's called in is private async static void MainGeomethod() so it can't be that either. Any advice as to what is causing this issue?


回答1:


After some looking I found that the assembly file I needed was actaully not on the list of possible references but had to be found in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll



来源:https://stackoverflow.com/questions/38750835/geolocation-get-location-async-cannot-be-awaited

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