【问题标题】:How to handle "The notification platform is unavaible", System Exception如何处理“通知平台不可用”、系统异常
【发布时间】: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


【解决方案1】:

此页面显示此时不可用的 API: https://ms-iot.github.io/content/en-US/win10/UnavailableApis.htm

如果这不适用于您的方案:

if (ApiInformation.IsTypePresent("Windows.ApplicationModel.Background.ToastNotificationActionTrigger"))
  {
     //put your line here which otherwise has an exception
  }

那么你可能需要尝试……除了这条线。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-31
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    相关资源
    最近更新 更多