Skip to content

Regression: InvalidCastException when trying to get string array from ApplicationData #2068

@tipa

Description

@tipa

Description

This is the same issue that has been fixed before here, but with .net10-rc1 it surfaced again.

Describe the bug

When building the app with PublishAot=true, getting a string array from ApplicationData.Current.LocalSettings and casting it to the string[] type I get:
System.InvalidCastException: 'Unable to cast object of type 'WinRT.IInspectable' to type 'System.String[]'.'

image

Steps To Reproduce

Set in csproj:
<PublishAot>true</PublishAot>

ApplicationData.Current.LocalSettings.Values["test"] = new string[] { "a", "b", "c" };
var array = (string[])ApplicationData.Current.LocalSettings.Values["test"];

Expected Behavior

No crash

NuGet package version

Windows App SDK 1.8.0: 1.8.250916003

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2

IDE

Visual Studio 2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions