0
我正在寫一個玩具桌面應用程序,它與作爲WinRT的一部分的LockScreen
API交互,並使用async/await
。按照指示here後,我已經啓用支持WinRT中,並添加以下引用:在帶有LockScreen API的桌面上使用WinRT
System.Runtime.dll
System.Runtime.WindowsRuntime.dll
System.Runtime.InteropServices.WindowsRuntime.dll
但是我仍然得到這個錯誤,而建設:
'System.Runtime.CompilerServices.TaskAwaiter' does not contain a definition for 'IsCompleted'
錯誤與關聯await
我的代碼行。我還有什麼遺漏?
編輯:這裏是有問題的代碼和項目的引用的完整列表。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using Windows.System.UserProfile;
using System.IO;
using Windows.Storage.Streams;
public class Program : Form
{
[STAThread]
static void Main()
{
...
}
public Program()
{
string wallpaper = ...
...
SetLockScreenImage(wallpaper);
}
private async void SetLockScreenImage(string path)
{
InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
...
await LockScreen.SetImageStreamAsync(ras);
}
}
參考
Microsoft.CSharp
System
System.Core
System.Data
System.Data.DataSetExtension
System.Deployment
System.Drawing
System.Runtime
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.WindowsRuntime
System.Windows.Forms
System.Xml
System.Xml.Linq
Windows
你可以分享代碼與完整的參考列表添加? –
@IrisClasson新增了! – SteveStifler
您使用的是哪個版本的.NET?您是否嘗試過添加Microsoft.Bcl.Async NuGet包,在某些缺失的平臺上添加了對異步/等待的全面支持? https://www.nuget.org/packages/Microsoft.Bcl.Async/ –