问题描述
我正在创建一个c#表单应用程序(重要的是要注意它不是一个移动应用程序,因为我认为这是问题的一部分)。我正尝试使用Windows设备地理位置库,但我遇到了Microsoft网站上给出的代码无法运行的问题。
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();
这段代码应该可以正常工作,但我得到的错误是IAsyncOperation不包含getawaiter的方法,扩展方法接受IAsyncOperation的第一个参数是什么导致了这种情况。我知道它说你需要在声明中使用系统,但我有这个,所以它不可能是这样。是什么导致了这个问题?注意它调用的方法是 private async static void MainGeomethod()
,所以它也不能这样。任何建议是什么导致这个问题?
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?
推荐答案
在看了一些后我发现我需要的程序集文件是有效的可能引用的列表,但必须在C:\程序文件(x86)\引用程序集\ Microsoft \ Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll中找到
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
这篇关于地理位置获取位置异步不能等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!