未经本人允许,禁止转发,抄袭!
1、使用的为 Windows.Devices.Bluetooth
2、使用的是windows设备蓝牙,和两个外接蓝牙进行通信,外界蓝牙通过串口调试工具进行收发数据显示。
3、本计算机系统为win10,支持版本为win8以上,但未尝试win8
4、原工程为UWP实现,改为C#控制台实现,winform也可以(都为.NET Framework,应该没问题,但未具体操作)
出现问题及解决方式:
一、Windows.Devices.Bluetooth 等命名空间不存在:
1、卸载该项目:右键->卸载项目,然后需要修改 “工程.csproj” ,在其中增加:

我使用的是win10 ,所以中间为10.0
2、重新加载该项目:右键->重载项目
3、添加引用:这时引用中会出现:“Universal Windows”,在里面找到“Windows.Devices”和"Windows.Security"进行添加,在我解决的时候只添加了一个,然后再想去添加的时候,引用管理器中已经没有这些引用了。如果出现这种情况,手动添加,这两个引用存在的目录是“C:\Windows\System32\WinMetadata\”,名称是:“Windows.Security.winmd”和“Windows.Storage.winmd”

引用管理器中会出现蓝框所示集合
https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applications
中有详细步骤
二、Could not load file or assembly ‘Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime’:
升级.NET Framework,我所使用的是4.7.1。
三、System.Runtime报错:
基本上升级.NET后就解决了,如果还报错,手动添加该引用,引用的目录在"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll",使用v4.5或者更高就可以
四、其他错误:
基本上按提示添加引用就可以了
参考:https://stackoverflow.com/questions/37333179/is-there-any-way-to-use-bluetooth-le-from-a-c-sharp-desktop-app-in-windows-10
https://stackoverflow.com/questions/37818576/bluetooth-low-energy-in-net-c
https://stackoverflow.com/questions/24670855/cannot-register-windows-devices-bluetooth
https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applications
https://stackoverflow.com/questions/14313216/could-not-load-file-or-assembly-windows-version-255-255-255-255-culture-neutr

5999

被折叠的 条评论
为什么被折叠?



