I've been trying to fix this problem for an hour now and it's been giving me a headache. All I'm trying to do is connect a Bluetooth device to my application using the example on this page. When the .Connect function is called, a SocketException occurs saying "The requested address is not valid in its context".
I am positive the address of the device I'm pairing is correct; I even discovered devices and used an address from one of the found devices, yet I still got the same error. I've tried both BluetoothService.SerialPort and the MyConsts class example for the Guid, and both raised the same error.
The code I'm using is here:
BluetoothAddress addr = BluetoothAddress.Parse("78A2A0FC0BB1");
Guid serviceClass;
serviceClass = BluetoothService.SerialPort;
// - or - etc
// serviceClass = MyConsts.MyServiceUuid
//
var ep = new BluetoothEndPoint(addr, serviceClass);
var cli = new BluetoothClient();
cli.Connect(ep);
Stream peerStream = cli.GetStream();
I'm also using Visual Studio 2015.
According the documentation it is not issue with the address itself but with services that are running on the device.
https://32feet.codeplex.com/wikipage?title=Errors
No Service with given Service Class Id is running on the remote device
Are you sure that device you are using has SerialPort profile running?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With