无法注册Windows.Devices.Bluetooth

Bri*_*ian 2 c# windows dll bluetooth

我一直在尝试注册Windows.Devices.Bluetooth,以便我可以使用http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.rfcomm.aspx上的代码.

即使我从VS 2013 Pro Update 3和Windows 8 SDK安装了SDK,但我找到这些程序集的唯一位置是在C:\ Windows\System32文件夹中.

当我尝试将它们注册到我的项目中时,我收到了"无法添加"对C:\ Windows\System32\Windows.Devices.Bluetooth.dll'的引用.请确保该文件可访问,并且它是一个有效的程序集或COM组件."

我在运行VS作为管理员时没试过这个.

其他人都有这个问题,你是如何克服这个障碍的?

Bri*_*ian 6

解决方案是一切的组合.

  1. 添加<TargetPlatformVersion>8.0</TargetPlatformVersion>到csproj
  2. 将"Windows.winmd"添加到您的引用中.
  3. 将C:\ Program Files(x86)\ Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\System.Runtime.dll添加到引用.

作为核心一部分的默认System.Runtime不包含Windows.winmd需要执行任何操作的System.Attribute.

这意味着只要我的部署目标是Windows 8.0及更高版本,我现在就可以构建桌面控制台应用程序以使用蓝牙.

  • 我相信我已经解决了这个问题.将TargetPlatformVersion更改为8.1似乎让我可以访问蓝牙命名空间. (2认同)