Bluetooth Library (March Edition)

To facilitate using the library in Visual Studio 2005 Betas I have made a few minor updates to the managed Bluetooth library, new/fixed in this release:-

  • Now works under .NETCF 1.0, .NETCF 2.0, .NET 1.1 .NET 2.0 (Not tested under the .NET 1.0 desktop framework but should work).
  • On Windows CE remote name lookups are performed “on-demand” rather than during device discovery to reduce discovery time.
  • Reintroduced the BluetoothSocket helper class which provides a shortcut to create a Socket for working with Bluetooth independently of the existing BluetoothClient / BluetoothListener classes.
  • Removed OpenNETCF.dll dependency, cures deployment problems on desktop machines.

Download the latest version here:-



By Peter Foot

Microsoft Windows Development MVP

18 replies on “Bluetooth Library (March Edition)”

I am trying to create a sample Bluetooth Application on the Desktop (using .NET 1.1) however when I initiate the BluetoothClient Class I get the error: "An address incompatible with the requested protocol was used".

I apppreciate if you could advice what may be the cause of this error.

Thank You

Does this version support the Bluetooth.BluetoothSecurity class under the Desktop platform (.NET 1.1)?

Also, If I would like to react on an authenticate request from remote device to my Desktop app., how should I implment it at the moment?


I have added a call in BluetoothClient that attempts to send a connection into Sniff mode, but im getting an invalid socket option or level in SetSocketOption. Is this functionality not supported by windows, or am I not making the call correctly?

Also, I cant seem to register on the forum. i click ‘agree’ and i get the same page again.

please help

To reiterate – this library only works with the Microsoft Bluetooth stack. HP use Broadcom (nee Widcomm) stacks in their iPaqs so you can’t use this library with them.


I have downloaded v1.2.50312 and get the following error in the bluetoothchat application in the chatform.cs (at line 07 in the clip below)

I only get the error on my HP Ipaq hx4700, not in the emulator.

An unhandled exception of type ‘System.Net.Sockets.SocketException’ occurred in System.dll

Additional information: An address incompatible with the requested protocol was used

01 public class ChatForm : System.Windows.Forms.Form
02 {
03 internal System.Windows.Forms.MainMenu MainMenu1;
04 const int MAX_MESSAGE_SIZE = 128;
05 const int MAX_TRIES = 3;
06 private System.Guid ServiceName = new System.Guid("{E075D486-E23D-4887-8AF5-DAA1F6A5B172}");
07 OpenNETCF.Net.Sockets.BluetoothClient btClient = new OpenNETCF.Net.Sockets.BluetoothClient();
08 OpenNETCF.Net.Sockets.BluetoothListener btListener;
09 private bool listening = true;
10 string str;
12 public ChatForm()
13 {
14 //base.New();
15 InitializeComponent();
16 }

any help would be appreciated

If I am * not using OpenNETCF *, can I still write a C# application for a PocketPC which will be able to discover other bluetooth devices and communicate with them.

If it is possible, please let me know more about it or any links if you have any.




I have a MSI bluetooth dongle connected to my pc. I believe this dongle uses the widcomm stack and thus the library doesnt work. Do you know what dongles use the microsoft stack?

AFAIK High Point ( have the only third party library which supports both MS and Widcomm stacks for .NET. I don’t know whether it is just for devices or if it also supports the desktop.

With regards which dongles are supported, I don’t know of a definitive list, XP SP2 ships with generic drivers which will work with most dongles, to test that theory you can try uninstalling the Widcomm software and restart your machine and see if the dongle is detected as a known bluetooth radio device in which case the MS stack will be installed.


Also – I wanted to stream voice over bluetooth. I dont think OpenNETCF has a library for streaming. Does it? Please let me know if there is any library available for that and prefereably under the managed environment.

Thanks for the tip, its working fine now that I uninstalled the device’s drivers.

I have a few questions regarding the bluetooth framework:

1. Is it possible to get the remote device id from a bluetoothclient object?

2. How to Get Local Device Id?

3. In your example the max bluetooth message is set to 128. Is there a reason for this? For example efficiency? Or is any size that suits the application good?



1. Currently no because the socket is a protected member – you’d have to derive a class from BluetoothClient to access it and its remote endpoint. But since you use BluetoothClient for outgoing connections you should already know the remote address from when you established the connection

2. Local device information can be retrieved from the BluetoothRadio class (InTheHand.Net.Bluetooth.BluetoothRadio)

3. Once the connection is established you have a socked with associated network stream so you can pass whatever data you want, depending on the application

As a reminder the Bluetooth library is documented here:-


Hi Peter,

I’m having problems having my (desktop) bluetooth device to listen for two different services.

I am setting up the listeners as so:
BluetoothListener btlisten = new BluetoothListener(_serviceId);

and waiting for a connection as so:
BluetoothClient btclient = btlisten.AcceptBluetoothClient();

The _serviceId parameter are two different GUIDs. I have tried listening for one service at a time and each service works, however when running the two together (using threads) the listener does not accept the connection and the client side throws an exception "The remote machine has actively refused the connection".

Can a bluetooth device only listen for a single service?


Ignore my previous comment,

The problem was that I was trying to discover devices while awaiting an incoming connection. Sorry.


Hi Peter,

I want to communicate via my Smartphone with an embedded device that has no bluetooth drivers on it. The embedded device is attached to a serial to bluetooth device. The serial to bluetooth supports the serial port profile. So I can communicate through there.

However, I’d like to know what profile the BluetoothClient/BluetoothListener class uses to communicate to see if it is possible to communicate in this manner to serial to bluetooth. So, what profile would it require?

I want to utilize bluetooth in my PDA agnostic application to receive barcode scans, without having two seperate code bases (one for each of the Bluetooth stacks). I understand that the OpenNET library only supports the Microsoft Bluetooth stack. If I have a device with the Broadcom Stack, is it possibile to overwrite/replace the stack with Microsofts? Or should I explore builing a COM port listner into my app?

Hi, I’m using opennetcf bluetooth api.
I would associate a bluetooth address to PC that listen for incoming connection coming from Pocket PC Device!
I found an excellent code samples about the bluetooth connection between PC and Pocket PC, but in this example pocket pc search the PC bluetooth address through DiscoverDevice method by BluetoothClient! I would associate a bluetooth address to PC, so only pocket pc devices that know the Listener address can call it!!! I try with BluetoothAddress class, but then how can I handle this object with the Listener device???

Thank you very much in advance!!

Comments are closed.