简体   繁体   English

在控制台中使用带有UWP参数的ApplicationData

[英]ApplicationData using in Console with UWP parameters

I'm trying to follow UWP with Desktop Extension – Part 2 of UWP and WinForms desktop-bridge calling the processes and passing parameters. 我正在尝试将UWP与Desktop Extension结合使用-UWP的第2部分和WinForms桌面桥调用进程并传递参数。 This example Console Program.cs code includes parameters string: 此示例Console Program.cs代码包含参数字符串:

 string parameters = ApplicationData.Current.LocalSettings.Values["parameters"] as string;

But the name ApplicationData does not exists in the current context, I'm trying to find out, if I've missed some reference or it is different version of C# 但是名称ApplicationData在当前上下文中不存在,我试图找出是否错过了一些参考或者它是C#的不同版本

I'm not sure even if it is what it requires, but adding of reference Windows.Foundation.UniversalApiContract.windmd throws another error with Values : 我不确定它是否是必需的,但是添加参考Windows.Foundation.UniversalApiContract.windmd会引发另一个Values错误:

Error CS0012 The type 'IPropertySet' is defined in an assembly that is not referenced. 错误CS0012在未引用的程序集中定义了“ IPropertySet”类型。 You must add a reference to assembly 'Windows.Foundation.FoundationContract 您必须添加对程序集'Windows.Foundation.FoundationContract的引用

@Nico Zhu - MSFT is correct, but I would also suggest alternative approach, which may make your life easier in the long run - the UWP APIs for desktop apps are now also distributed via NuGet as a package which takes care of referencing the right libraries for you. @Nico Zhu-MSFT是正确的,但我也建议您使用其他方法,从长远来看,这可能会使您的生活更轻松-桌面应用程序的UWP API现在也通过NuGet分发为软件包 ,用于处理引用正确的库的工作为了你。

It is in preview at the time of writing, so you can install as follows: 在撰写本文时它处于预览状态,因此您可以按以下方式安装:

Install-Package Microsoft.Windows.SDK.Contracts -Version 10.0.18362.2002-preview

See the NuGet page for more info. 有关更多信息,请参见NuGet页面

If you want to use ApplicationData class, please add Windows.winmd where in the C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.17134.0\\Windows.winmd . 如果你想使用ApplicationData类请加Windows.winmd其中在C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.17134.0\\Windows.winmd Then add Windows.Storage namespace. 然后添加Windows.Storage命名空间。

Detail steps 详细步骤

Right click project References -> Add References -> Browse(file type all file)-> select Windows.winmd 右键单击项目引用->添加引用->浏览(文件类型为所有文件)->选择Windows.winmd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM