Skip to content

AppNotificationBuilder.BuildNotification fails with ComException when the character ' appears on an AppNotificationButton #4996

@marticliment

Description

@marticliment

Describe the bug

When trying to create a AppNotificationBuilder, buttons can't contain the ' character, or otherwhise when calling the builder.BuildNotification method the following COMException will be thrown:

System.Runtime.InteropServices.COMException (0xC00CE509): Required white space was missing.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.Microsoft.Windows.AppNotifications.Builder.IAppNotificationBuilderMethods.BuildNotification(IObjectReference _obj)
at Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.BuildNotification()
at C:\My\Path\MyFile.cs:line 128

Steps to reproduce the bug

IMPORTANT: This bug is only reproducable when the solution is built as "Release", as "Debug" builds will work without further issues

The following code causes the issue:

// This line will always work
AppNotificationBuilder builder = new AppNotificationBuilder()
    .SetScenario(AppNotificationScenario.Default)
    .SetTag("UpdatesNotifications")

    .AddText("Adding a ' here is fine. They work as expected and don't crash")
    .AddText("More text")
    .SetAttributionText("Some attribution")

    .AddButton(new AppNotificationButton("Adding a ' here causes the COMException"))
        .AddArgument("action", "action1")
    )
    .AddButton(new AppNotificationButton("Another button")
        .AddArgument("action", "action2")
    )
    .AddArgument("action", "action3");

// The COMException occurrs on the line below
AppNotification notification = builder.BuildNotification();

Expected behavior

Notifications to support ' characters on buttons.

Screenshots

N/A

NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Other

Additional context

I have tried escaping the ' character by \\' with no luck,

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NotificationsToast notification, badges, Live Tiles, push notifications

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions