2016-07-14 22 views
0

マイコンピュータは、以下のコードによって返されるべき作業スマートカードリーダーを持っている:コードスニペットはMicrosoft's C# Sample Codeawait構文を使用してWindows.Devices.Enumeration.DeviceInformation.FindAllAsyncから結果を読み取る方法?

からコピーされ

Error CS4036 ' IAsyncOperation<DeviceInformationCollection> ' does not contain a definition for ' GetAwaiter ' and no extension method ' GetAwaiter ' accepting a first argument of type ' IAsyncOperation<DeviceInformationCollection> ' could be found (are you missing a using directive for ' System '?)

string selector = Windows.Devices.SmartCards.SmartCardReader.GetDeviceSelector(); 
Windows.Devices.Enumeration.DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(selector); 

はしかし、私はこのエラーを取得しています

このエラーを解決するにはどうすればよいですか?

答えて

3

エラーメッセージは、何が間違っているかについてのヒントを提供しています。ファイルの先頭にusing System;ディレクティブを追加します。

将来的には、MSDNで問題の拡張メソッドを検索することで、これを追跡することができます。 「IAsyncOperation GetAwaiter拡張メソッド」を検索します。私がそれを行うと、最初のページはWindowsRuntimeSystemExtensions.GetAwaiter Method (IAsyncOperation)であり、そのページでは、メソッドがSystem名前空間にあり、System.Runtime.WindowsRuntime.dllアセンブリで定義されていることがわかります。これらの2つの情報で、.csファイルにusing System;があることと、プロジェクトにSystem.Runtime.WindowsRuntime.dllというアセンブリ参照があることを確認することができます。

関連する問題