简体   繁体   English

32feet .NET api拒绝连接“请求的地址在其上下文中无效”

[英]32feet .NET api refusing to connect “The requested address is not valid in its context”

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". 调用.Connect函数时,会发生SocketException,说“请求的地址在其上下文中无效”。

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. 我已经为Guid尝试了BluetoothService.SerialPort和MyConsts类示例,并且都引发了同样的错误。

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. 我也在使用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 https://32feet.codeplex.com/wikipage?title=Errors

No Service with given Service Class Id is running on the remote device 远程设备上没有运行具有给定服务类ID的服务

Are you sure that device you are using has SerialPort profile running? 您确定您使用的设备是否正在运行SerialPort配置文件?

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

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