【发布时间】:2015-07-02 13:39:44
【问题描述】:
我正在使用 Visual Studio 2015 Rc 在 Windows 10 上工作。我开发了一个发送 toast 通知的通用应用程序。我注意到在 RaspberryP2 上部署应用程序时,我收到此异常:
WinRT 信息:通知平台不可用。
没关系,我真的不需要在物联网设备上显示通知,我只是让它运行而不扔。
抛出的代码:
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements[0].AppendChild(toastXml.CreateTextNode("Title"));
stringElements[1].AppendChild(toastXml.CreateTextNode("Text"));
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
如果应用在 Windows 10 IoT 上运行,如何避免运行此代码?
(我正在寻找类似if (NotificationsAvaibible) { } else { }
【问题讨论】:
-
它被标记为通用 API 合约的一部分,因此它应该在物联网上有一个非抛出的实现。我会跟进的。
-
@PeterTorr-MSFT 这个问题在 VS 2015 RTM 和 Windows IoT core 10.0.10556 中仍然存在。
-
是的,VS 更新不会解决任何问题。您需要一个固定的 IoT 构建。不知道什么时候,抱歉。
标签: c# exception-handling windows-10 iot windows-10-iot-core