小编K. *_*sen的帖子

在命名空间“System.IO.Ports”中找不到类型名称“SerialPort”

我正在使用 Visual Studio Community 2019 编写一个新的串口下载程序。我对 C# 比较陌生,但必须维护一个大型 C# 应用程序,该应用程序也使用串行端口来配置嵌入式设备。

有问题的(新)代码如下。“System.IO.Ports”using 语句没有任何效果(显示为灰色),问题是编译器不知道“SerialPort”是什么(请参阅代码后面的错误)。

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Ports;
using System.Drawing;

namespace PangeaUpdater
{
    class Download
    {
        const byte STX_CHAR = (byte)'\x2';
        const byte ETX_CHAR = (byte)'\x3';
        const byte DLE_CHAR = (byte)'\x10';

        const int MAX_DATA_PACKET_LEN = 128;
        private BinaryReader pkgStream = null;

        public SerialPort serialPort;

        private void Create(String comPort, String baudrate,         
            System.Windows.Forms.RichTextBox msgListBox,
            System.Windows.Forms.ProgressBar progressBar)
        {
            //Lots of stuff should be configurable but is not (yet)
            serialPort …
Run Code Online (Sandbox Code Playgroud)

c# reference visual-studio

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×1

reference ×1

visual-studio ×1