2
我一直在試圖解決這個問題一個小時,它一直讓我頭痛。我所要做的就是使用示例on this page將藍牙設備連接到我的應用程序。當調用.Connect函數時,會發生一個SocketException,說「請求的地址在其上下文中無效」。32feet .NET API拒絕連接「請求的地址在其上下文中無效」
我認爲我配對的設備的地址是正確的;我甚至發現了設備並使用了其中一個找到的設備的地址,但我仍然遇到了同樣的錯誤。我已經嘗試了Guid的BluetoothService.SerialPort和MyConsts類示例,並且都引發了相同的錯誤。
我正在使用的代碼是在這裏:
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();
我也使用Visual Studio 2015年
您應該將相關代碼添加到問題本身,而不是鏈接到外部網頁。 –