Using ApplicationData in Windows WPF and UWP

Semi-Important Background

I am trying to change a UWP project to a Windows desktop application so that I can use the full .NET Framework 4.5.2. My solution also contains a second project, the Windows Runtime component, which manages background tasks. These background tasks are written to ApplicationData, so the main GUI project can use this information. I did the main project for a Windows application, not for UWP, but one problem remains:

Problem

Any reference to ApplicationData.Current.LocalSettings.Values, such as

ApplicationData.Current.LocalSettings.Values.Keys.Contains(myDataIndex) 

leads to the following error:

Error CS0012 The type "IPropertySet" is defined in an assembly that is not referenced. You must add a reference to the assembly  'Windows.Foundation.FoundationContract, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = null, ContentType = WindowsRuntime'. ProjectName C: \ Users \ MyUserName \ Documents \ Visual Studio 2015 \ Projects \ ProjectName \ ProjectName \ MainWindow.xaml.cs

So, for some reason, VS is confused about what it is IPropertySet.

I tried...

Unfortunately, nothing starts with Windows.Foundationa list of namespaces under Assemblies->Frameworkin the link manager.

Okay, so probably already out there, right ...? I will just try the usingrequired namespace. However, my project cannot find this Windows.Foundation.FoundationContractone because my project does not allow

using Windows.Foundation.FoundationContract

Windows.Foundation.Diagnostics Windows.Foundation.Metadata.

UWP, Metadata, Diagnostics Windows.Foundation.Collections. (, IPropertySet, Windows , Windows.Foundation.Collections).

, Windows.Foundation.Collections .NET Framework, Windows, UWP.NET Core...? , VS ApplicationData.Current.LocalSettings.Values, ? , .

Update

,

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd

per , .

( , Windows.winmd, . , - .)

, , , , UWP. , , ?

TL; DR

ApplicationData WPF ? ( UWP?

0

Source: https://habr.com/ru/post/1658007/


All Articles