首页 > 解决方案 > System.IO.IOException:向信号量发送了太多帖子

问题描述

我正在.net (Xamarin) 中开发一个应用程序,我正在尝试建立与串行端口的连接。每当我尝试打开与端口的连接时,都会收到此错误消息:

System.IO.IOException: '发送到信号量的帖子太多'

通过谷歌搜索找不到任何具体的内容。任何帮助表示赞赏!

示例代码:

private void Open()   
    {
        IsOpen = true;
        _serialPort.PortName = "COM3";
        _serialPort.BaudRate = 19200;
        _serialPort.Parity = Parity.None;
        _serialPort.DataBits = 8;
        _serialPort.StopBits = StopBits.One;
        _serialPort.Handshake = Handshake.None;
        _serialPort?.Open();
    }

标签: c#.netxamarinserial-portserial-communication

解决方案


这是因为您需要添加

<DeviceCapability Name="serialcommunication">
      <Device Id="any">
          <Function Type="name:serialPort" />
      </Device>
</DeviceCapability>

到您的 Package.appxmanifest。

我花了一段时间才自己弄清楚这一点。


推荐阅读