microsoft / Windows-Packaging-Samples

Windows Application Packaging Project Samples.
MIT License
55 stars 37 forks source link

Question: How to allow ApplicationData.Current.LocalSettings.Values in Packaged Forms App? #13

Closed myokeeh closed 3 years ago

myokeeh commented 3 years ago

I am trying to get back into modernizing a Forms app--I have been able o successfully submit it to the Store. All good there.

However, I'm trying to convert settings storage over to ApplicationData.Current.LocalSettings.Values instead of storing those in the registry. There's only a handful so it's ideal to convert.

Exception thrown at 0x00007FFD59FDD759 in FormsApp.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0000006B3EBF6B90.

I've been trying to check with this, but it currently never seems to have access to this API. Above is what I get if I just try using the ApplicationData.Current.LocalSettings.Values line without checking.

    if (ApiInformation.IsPropertyPresent("ApplicationData.Current.LocalSettings.Values", "Values"))
    {
    }

The Forms project currently has the Microsoft.Windows.SDK.Contracts 10.0.19041.1 Nuget installed.

From this blog post, it seems I should be able to do what I want but unsure what's keeping it from happening: https://blogs.windows.com/windowsdeveloper/2019/12/17/windows-10-sdk-preview-build-19041-available-now/

myokeeh commented 3 years ago

I ended up using try-convert to get it over to .NET 5. This API seems to work on that now.