我正在使用Visual Studio 2017专业版。
我一直在遵循本指南:
https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/notification-listener
我的问题代码如下:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Windows.UI.Notifications;
using System;
namespace SeleniumWebChat.Utilities
{
// This class handles Windows 'Toast' notifications that pop up when a new webchat/call is received
static class WinNotificationHandler
{
static async Task<bool> TaskCheckWinNotification(string notifType, string guest)
{
Windows.UI.Notifications.Management.UserNotificationListener listener = Windows.UI.Notifications.Management.UserNotificationListener.Current;
//only read notifications if we have access - this may need to be set in windows settings
if (listener.GetAccessStatus().ToString() == "Allowed")
{
// Get the windows toast notifications as a list
IReadOnlyList<UserNotification> notifs = await listener.GetNotificationsAsync(NotificationKinds.Toast);
//Console.Error.WriteLine("number of notifications found: " + notifs.Count());
}
return false;
}
}
}
问题在于此行:
IReadOnlyList<UserNotification> notifs = await listener.GetNotificationsAsync(NotificationKinds.Toast);
给出错误:
'IAsyncOperation<IReadOnlyList<UserNotification>>'
不包含'GetAwaiter'的定义,找不到扩展方法'GetAwaiter'接受类型为'IAsyncOperation<IReadOnlyList<UserNotification>>'
的第一个参数(您是否缺少'System'的using指令?)
我已经尝试了所有可以在网上找到的内容,从添加引用到以下内容:
C:\ Program Files(x86)\ Reference Assemblys \ Microsoft \ Framework.NETCore \ v4.5 \ System.Runtime.WindowsRuntime.dll
C:\ Program Files(x86)\ Windows Kits \ 10 \ UnionMetadata \ Facade \ Windows.WinMD
要添加NuGet软件包:
桌面桌面
Microsoft.NETCore.UniversalWindows平台
重新安装VS并尝试不同版本的SDK。
我真的不知道是什么导致了这个问题,对于任何朝着正确方向提出的建议,我将不胜感激。
参考方案
您应该添加
using System.WindowsRuntimeSystemExtensions;
这来自System.Runtime.WindowsRuntime程序集,并包含具有GetAwaiter扩展的类。
AJAX调用只能与$(document).on('click')一起使用 - php我有一个显示数据库条目的表。用户能够为每一行打开一个弹出菜单。选项之一是删除数据库条目,并且该表应通过AJAX调用相应地刷新。只要有人单击#delete-toggle中的table-popup,我就会在HTML页面上进行AJAX调用(table-popup是div,当有人单击每行中存在的表中的table-edit-button时出现的表): <div …
使用php重新加载内容 - javascript在对网站进行编程时,我以前使用过此代码,它可以完美工作,但是现在当我想使用一些Flash部件时,每次单击链接时,它都会重新加载所有网站。源代码: <!DOCTYPE html> <html> <head> <title>Hot King Staff</title> <meta charset=…
在laravel中应用ajax - javascript我想在laravel 4.2中应用ajax。我想重定向到页面而不重新加载它。我已经尝试过使用window.loaction.href和window.loaction.assign了,但是它不起作用。这是我的文件Route.php //login+logout+auth Route::get('login','authentica…
通过电子邮件发送库存状态表 - javascript我正在寻找一种通过电子邮件发送具有相同HTML结果的产品确认页(带有可用输入)的解决方案。我对从mail.php的确认页面获取输入不感到困惑。请在下面找到代码。谢谢stockdetailform.php<html> <head> <title>Stockr Form</…
尽管刷新,jQuery格式仍未应用于Ajax数据 - javascript我正在通过GET响应消息从服务器(php文件)的可折叠内部加载列表视图。但是,尽管刷新了jQuery元素,但jQuery格式并未应用于添加的HTML。我的页面在这里:http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.htmlHTML代码(仅相关代码)<script> lastRecor…