'ToastNotification' does not contain a definition for 'Data' on Windows Server 2016

浪子不回头ぞ 提交于 2019-12-13 04:22:51

问题


I unable to build my Toast Progress Bar solution on a build server after succesful build locally.

Errors on build server:

Error CS0117: 'ToastNotification' does not contain a definition for 'Data'

Error CS0246: The type or namespace name 'NotificationData' could not be found (are you missing a using directive or an assembly reference?)

Error CS1061: 'ToastNotifier' does not contain a definition for 'Update' and no accessible extension method 'Update' accepting a first argument of type 'ToastNotifier' could be found (are you missing a using directive or an assembly reference?)

My code:

public void ShowProgress()
{
    var definition = new XElement("toast");
    definition.Add(new XElement("visual", new XElement("binding", new XAttribute("template", "ToastGeneric"),
        new XElement("text", caption),
        new XElement("progress",
        new XAttribute("title", "{progressTitle}"),
        new XAttribute("value", "{progressValue}"),
        new XAttribute("status", "Downloading...")))));
    var data = new Dictionary<string, string>
        {
            { "progressTitle", string.Empty },
            { "progressValue", "0.00" }
        };

    var toast = new ToastNotification(ToXmlDocument(definition))
    {
        Tag = progressTag,
        Data = new NotificationData(data, sequenceNumber)
    };

    ToastDesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
}

public void UpdateProgress()
{
    ...
}

Our build servers are Windows Server 2016 and my developer box is Windows 10 1803, both has VS 2017 installed. At first I thought that I was just missing the Windows 10 SDK (10.0.15063.0) as this is required for the progress functionality but this and newer is already installed.

NotificationData is situated in Windows.UI.dll which is located in c:\Windows\System32\ and not in the Windows SDK directory. So this explains why the dll is older and missing types on my build server.

So the question is whether it is possible to build my progress code on a Windows Server 2016 or I am forced to upgrade to 2019?

来源:https://stackoverflow.com/questions/55899493/toastnotification-does-not-contain-a-definition-for-data-on-windows-server-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!