C# ';Windows.Storage.StorageFile File=wait FilePicker.PickSingleFileAsync()';不起作用
我有以下代码显示应用程序中的文件选择器:C# ';Windows.Storage.StorageFile File=wait FilePicker.PickSingleFileAsync()';不起作用,c#,xaml,compiler-errors,win-universal-app,C#,Xaml,Compiler Errors,Win Universal App,我有以下代码显示应用程序中的文件选择器: var FilePicker = new Windows.Storage.Pickers.FileOpenPicker(); FilePicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; FilePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.ComputerFolder; F
var FilePicker = new Windows.Storage.Pickers.FileOpenPicker();
FilePicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
FilePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.ComputerFolder;
FilePicker.FileTypeFilter.Add(".pcs");
FilePicker.FileTypeFilter.Add(".pcp");
Windows.Storage.StorageFile File = await FilePicker.PickSingleFileAsync();
但是,Windows.Storage.StorageFile File=wait FilePicker.PickSingleFileAsync()
在编译过程中会导致此错误:
错误CS4036“IAsyncOperation”不包含
“GetAwaiter”和无扩展方法“GetAwaiter”的定义
接受类型为“IAsyncOperation”的第一个参数
找不到(是否缺少“系统”的using指令?)
为什么会这样?我从MSDN那里得到了密码。谁能帮帮我吗
注意:我正在为通用Windows编程。您在使用中缺少对
系统的明显引用
using System;
为什么您需要这个引用,为什么它抱怨它缺少一个看似未使用的方法
使用await
,它实际上调用了WindowsRuntimeSystemExtensions.GetAwaiter
,这是对IAsyncOperation
的一种扩展方法(用于获取要等待的TaskAwaiter
)。由于WindowsRuntimeSystemExtensions
驻留在System
命名空间中,您需要using
来获得扩展方法。您是否有所指示的系统使用指令?如果在using
指令中也出现大量错误,然后试着跟随——从一些项目的未知原因开始,你需要阅读nuget包。希望IntelliSense
能够更智能地检测这样一个非常简单的错误