简体   繁体   English

C#中的蓝牙库

[英]Bluetooth library in C#

I recently downloaded 32Feet.NET library to work with Bluetooth Radio Device in C#. 我最近下载了32Feet.NET库,用于在C#中使用蓝牙无线电设备。 When i tried to run a sample program included with 32feet library set up file i am getting this error message 当我试图运行32feet库设置文件中包含的示例程序时,我收到此错误消息

Error 1 The type or namespace name 'InTheHand' could not be found (are you missing a using directive or an assembly reference?) 错误1找不到类型或命名空间名称“InTheHand”(您是否缺少using指令或程序集引用?)

https://32feet.codeplex.com/wikipage?title=Referencing%20the%20library https://32feet.codeplex.com/wikipage?title=Referencing%20the%20library

Says: 说:

Referencing the Library 引用库

The library is provided as an assembly with name InTheHand.Net.Personal.dll . 该库以名为InTheHand.Net.Personal.dll的程序集提供。 The installer arranges that it can be selected directly from Visual Studio's Add Reference dialog. 安装程序会安排可以直接从Visual Studio的“添加引用”对话框中选择它。

Note: Many of the recent version of the library were provided as ZIP files alone and don't included an installer script/program; 注意:许多最新版本的库仅作为ZIP文件提供,不包含安装程序脚本/程序; they do not add the library to the .NET tab, instead you'll need to "Browse" to the library on disk. 他们不会将库添加到.NET选项卡,而是需要“浏览”到磁盘上的库。

[...] [...]

Like the classes in the standard network library, the library classes in 32feet.NET are in a number of namespaces. 与标准网络库中的类一样,32feet.NET中的库类具有许多名称空间。 One or more Imports (VB) / using (C#) directives will thus be required. 因此将需要一个或多个Imports (VB)/ using (C#)指令。 For example: 例如:

Imports InTheHand.Net // e.g. BluetoothAddress, BluetoothEndPoint etc
Imports InTheHand.Net.Sockets // e.g. BluetoothDeviceInfo, BluetoothClient, BluetoothListener
Imports InTheHand.Net.Bluetooth // e.g. BluetoothService, BluetoothRadio

check that you have the reference to InTheHand and that you have a using InTheHand on the code. 检查您是否有对InTheHand引用 ,并且您在代码中using InTheHand

[EDIT] [编辑]

1) see that you have the using InTheHand in the top of your code. 1)看到您在代码顶部using InTheHand

2) if a wiggly red line appear under the line it means you need to reference a library where the name-space is. 2)如果线下出现一条摆动的红线,则表示您需要引用名称空间所在的库。

3) Normally the name-space and the name of the file match, this sometimes is not the case and on this cases you need to check the documentation, but first try and on the project right click and select "Add Reference" then in "Assemblies" try to find the name-space or the name of the library you are using, if you cant find it try on Assemblies->Extensions , if you steel cant find it then you try the DLL and to do this you chose the "Browse" and the path is the path you downloaded the file. 3)通常名称空间和文件名称匹配,有时情况并非如此,在这种情况下您需要检查文档,但首先尝试并在项目上右键单击并选择“添加引用”然后在“程序集“尝试查找名称空间或您正在使用的库的名称,如果您无法尝试使用Assemblies-> Extensions ,如果您无法找到它然后您尝试DLL并执行此操作,您选择了”浏览“并且路径是您下载文件的路径。

PS: when you install a new Library you need to restart your visual studio to let it load the new assemblies, most times restarting the machine is not needed but it cant harm. PS:当您安装新的库时,您需要重新启动Visual Studio以使其加载新的程序集,大多数情况下不需要重新启动机器但它不会造成伤害。

Check that your project has been targeted for compatible bitness to the 32feet library. 检查您的项目是否已针对32feet库的兼容性。 As of typing this, it's only available as a 32-bit DLL so make sure your project is targeted for x86 only. 在键入此内容时,它仅作为32位DLL提供,因此请确保您的项目仅针对x86。 Visual Studio is too dumb to tell you about this. Visual Studio太笨了,无法告诉你这件事。

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

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