Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用等待语法从Windows.Devices.Enumeration.DeviceInformation.FindAllAsync读取结果?_C#_Async Await_Winmd - Fatal编程技术网

C# 如何使用等待语法从Windows.Devices.Enumeration.DeviceInformation.FindAllAsync读取结果?

C# 如何使用等待语法从Windows.Devices.Enumeration.DeviceInformation.FindAllAsync读取结果?,c#,async-await,winmd,C#,Async Await,Winmd,我的计算机有一个可工作的智能卡读卡器,该读卡器应通过以下代码段返回: string selector = Windows.Devices.SmartCards.SmartCardReader.GetDeviceSelector(); Windows.Devices.Enumeration.DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(se

我的计算机有一个可工作的智能卡读卡器,该读卡器应通过以下代码段返回:

string selector = Windows.Devices.SmartCards.SmartCardReader.GetDeviceSelector();
Windows.Devices.Enumeration.DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(selector);
但是,我遇到了以下错误:

错误CS4036“
IAsyncOperation
”不包含“
GetAwaiter
”的定义,并且找不到接受类型为“
IAsyncOperation
”的第一个参数的扩展方法“
GetAwaiter
”(是否缺少“
系统
”的using指令?)

代码段是从中复制的


如何解决此错误?

错误消息为您提供了一个很好的错误提示。添加
使用系统指令添加到文件顶部


为了便于将来参考,您可以通过在MSDN中搜索有问题的扩展方法(例如,搜索“IAsyncOperation GetWaiter扩展方法”)来自行查找。当我这样做时,第一个页面是,在该页面上,您可以看到该方法位于
System
命名空间中,并在
System.Runtime.WindowsRuntime.dll
程序集中定义。有了这两条信息,您可以再次检查,以确保您有
使用系统,并且项目中有
System.Runtime.WindowsRuntime.dll
程序集引用。

错误消息为您提供了一个关于错误的非常好的提示。添加
使用系统指令添加到文件顶部

为了便于将来参考,您可以通过在MSDN中搜索有问题的扩展方法(例如,搜索“IAsyncOperation GetWaiter扩展方法”)来自行查找。当我这样做时,第一个页面是,在该页面上,您可以看到该方法位于
System
命名空间中,并在
System.Runtime.WindowsRuntime.dll
程序集中定义。有了这两条信息,您可以再次检查,以确保您有
使用系统,并且项目中有
System.Runtime.WindowsRuntime.dll
程序集引用