如何在Visual Studio 2017项目中包含Windows.Devices.HumanInterfaceDevice.dll

如何在Visual Studio 2017项目中包含Windows.Devices.HumanInterfaceDevice.dll

问题描述:


我想使用  HID
设备类
 在Visual Studio中的C#项目中

I want to use the HID Device class in a C# project in Visual Studio


我正在尝试将dll添加到引用,右键单击解决方案资源管理器中的参考部分>添加引用,并浏览到引用位置(C:/Windows/System32/Windows.Devices.HumanInterfaceDevice.dll)。我收到一个错误,询问
我是否拥有该文件的正确权限,或者它是否是一个有效的COM程序集。

I'm trying to add the dll to the references buy right clicking the reference section in the solution explorer > Add reference, and browsing to the reference location (C:/Windows/System32/Windows.Devices.HumanInterfaceDevice.dll). I get an error asking if I have the right permissions for the file, or if its a valid COM Assembly.


我应该如何正确导入这个dll?

How should I correctly import this dll?

嗨布拉德利,

欢迎来到MSDN论坛。

你的C#项目类型是什么?如果是
桌面  应用程序,请关注

此博客


  1. 右键单击
    参考文献。从上下文菜单中选择"添加引用..."。在
    参考管理器的左侧,选择"浏览"并找到以下文件:C:\Program Files(x86)\ Windows Wits\10\UnionMetadata \ Windows。 winmd。将其添加到项目中作为参考。注意:您需要将过滤器更改为"所有文件"。
  1. Right click on References. Select "Add Reference…" from the context menu. On the left of the Reference Manager, choose Browse and find the following file: C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd. Add it to your project as a reference. Note: You will need to change the filter to "All Files".



  1. 右键单击
    引用即可。从上下文菜单中选择"添加引用..."。在
    参考管理器的左侧,转到"浏览",找到目录"C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework \ .NETCore \v4.5" 。将
    System.Runtime.WindowsRuntime.dll 添加到您的项目中。
  1. Right click on References. Select "Add Reference…" from the context menu. On the left of the Reference Manager, go to Browse and find the directory "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5". Add System.Runtime.WindowsRuntime.dll to your project.


之后,您可以使用导入此Windows.Devices.HumanInterfaceDevice,如下所示:

祝你好运,

Sara