C# 蓝牙侦听器-如何侦听来自蓝牙设备的消息

C# 蓝牙侦听器-如何侦听来自蓝牙设备的消息,c#,bluetooth,serial-port,C#,Bluetooth,Serial Port,我正在尝试创建一个服务器(一台带有蓝牙的计算机)来侦听蓝牙消息。我用的是32英尺的图书馆。但我有个例外,我找不到它是什么。 例外情况是: 找不到支持的蓝牙协议堆栈 代码如下: using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using InTheHand; using InTheHand.Net.Bluetooth; using InTheHa

我正在尝试创建一个服务器(一台带有蓝牙的计算机)来侦听蓝牙消息。我用的是32英尺的图书馆。但我有个例外,我找不到它是什么。 例外情况是: 找不到支持的蓝牙协议堆栈

代码如下:

using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using InTheHand;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Ports;
using InTheHand.Net.Sockets;
using System.IO;


namespace Bluetoot_Tutorial
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void bGo_Click(object sender, EventArgs e)
    {

            connectAsServer();

    }

    private void connectAsServer()
    {
        Thread bluetoothServerThread = new Thread(new ThreadStart(ServerConnectThread));
        bluetoothServerThread.Start();
    }



    private void connectAsClient()
    {
        throw new NotImplementedException();
    }

    Guid uUUID = new Guid("00001101-0000-1000-8000-00805F9B34FB");

    public void ServerConnectThread()
    {
        BluetoothListener blueListener = new BluetoothListener(uUUID);
        blueListener.Start();
        BluetoothClient conn = blueListener.AcceptBluetoothClient();


    }

信息的意思是它所说的。。。您的电脑上有什么蓝牙软件?

在BluetoothListener中添加本地地址,如下所示

        BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio;
        if (myRadio == null)
        {
            Console.WriteLine("No radio hardware or unsupported software stack");
            return;
        }
        RadioMode mode = myRadio.Mode;
        var lsnr = new BluetoothListener(myRadio.LocalAddress, serviceClass);
        lsnr.Start();

另一方面,我建议您不要尝试在每次尝试时重复使用与此处相同的GUID,而是使用GUID.NewGuid(),然后为(尝试的)会话共享新实例化的GUID。谢谢,异常是否与库有关?我尝试了VP解决方案,但在同一行中仍然存在相同的异常。这是我得到异常的一行:BluetoothListener blueListener=new BluetoothListener(UUID);更改GUID不会解决此问题,它只是您可能需要更改的内容的旁注。然而,看起来您仍然需要更多的代码。我可能会建议你看看其他几个类似的帖子,这可能会给你一个很好的立足点:你查过谷歌了吗?