Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.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.Storage.StorageFile File=wait FilePicker.PickSingleFileAsync()';不起作用_C#_Xaml_Compiler Errors_Win Universal App - Fatal编程技术网

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
能够更智能地检测这样一个非常简单的错误