[英]How to add a Reference to the Windows.ApplicationModel.DataTransfer namespace in Visual Studio 2019 on Windows 10 PRO
Windows 10 Pro, Visual Studio 2019, .Net version 4.8.03752 (Clean installation of everything a few days ago). Windows 10 专业版、Visual Studio 2019、.Net 版本 4.8.03752(几天前干净安装所有东西)。
I'm trying to add the Windows.ApplicationModel.DataTransfer namespace to my C# project in Visual Studio 2019 (free edition).我正在尝试将 Windows.ApplicationModel.DataTransfer 命名空间添加到 Visual Studio 2019(免费版)中的 C# 项目。 I cannot find anything to add under References->Add References->Assemblies.
我在 References->Add References->Assemblies 下找不到任何要添加的内容。
The documentation for ClipboardContentOptions states that the dll is Windows.ApplicationModel.DataTransfer.dll so I search for the dll and find versions in ClipboardContentOptions 的文档指出 dll 是 Windows.ApplicationModel.DataTransfer.dll 所以我搜索 dll 并在
C:\\Windows\\System32 (799Kb) C:\\Windows\\SysWOW64 (566Kb), C:\\Windows\\System32 (799Kb) C:\\Windows\\SysWOW64 (566Kb),
I attempt to add these dlls via References->AddReference->Browse and in both cases get the error我尝试通过 References->AddReference->Browse 添加这些 dll,在这两种情况下都会出现错误
A Reference to <path to dll> could not be added. Please make sure that the file is accessible and that it is a valid assembly or COM component
What's going on here and how do I add a Reference to this namespace?这里发生了什么以及如何添加对此命名空间的引用?
Thanks in advance.提前致谢。
Windows.ApplicationModel.DataTransfer
is a WinRT API namespace. Windows.ApplicationModel.DataTransfer
是 WinRT API 命名空间。 The easiest way to gain access to these namespaces is to add the Microsoft.Windows.SDK.Contracts
NuGet package as follows:访问这些命名空间的最简单方法是添加
Microsoft.Windows.SDK.Contracts
NuGet 包,如下所示:
Open your project/solution in Visual Studio.在 Visual Studio 中打开您的项目/解决方案。
Ensure you are targeting .NET Framework 4.6.1+ or .NET Core 3.0+ per NuGet package requirements.根据 NuGet 包要求,确保您的目标是 .NET Framework 4.6.1+ 或 .NET Core 3.0+。
Convert any old package.config references in your project to the newer PackageReference format, by right-clicking the package.config reference and clicking Migrate package.config to PackageReference
.通过右键单击 package.config 引用并单击
Migrate package.config to PackageReference
,将项目中任何旧的 package.config 引用转换为较新的 PackageReference 格式。
In Solution Explorer, right-click References then click Manage NuGet References.在解决方案资源管理器中,右键单击“引用”,然后单击“管理 NuGet 引用”。
Click the Browse heading then type Microsoft.Windows.SDK.Contracts
into the search box.单击浏览标题,然后在搜索框中键入
Microsoft.Windows.SDK.Contracts
。
Click the Microsoft.Windows.SDK.Contracts
(trusted by Microsoft) package then click the Install button on the right.单击
Microsoft.Windows.SDK.Contracts
(受Microsoft.Windows.SDK.Contracts
信任)包,然后单击右侧的安装按钮。
Alternatively, you can add a reference to Windows.winmd
from the appropriate SDK folder typically located at C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata
.或者,您可以从通常位于
C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata
的相应 SDK 文件夹中添加对Windows.winmd
的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.