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

        private void button1_Click(object sender, EventArgs e)
        {
            serialPort1.PortName = "COM1";
            serialPort1.BaudRate = 9600;
             serialPort1.Open();
            byte[] data = Encoding.Unicode.GetBytes(textBox1.Text);
            string str = Convert.ToBase64String(data);
            serialPort1.WriteLine(str);
            MessageBox.Show("数据发送成功!", "系统提示");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            byte[] data = Convert.FromBase64String(serialPort1.ReadLine());
            textBox2.Text = Encoding.Unicode.GetString(data);
            serialPort1.Close();
            MessageBox.Show("数据接收成功!", "系统提示");
        }

    }
提示错误:
未处理 System.InvalidOperationException
  Message="端口被关闭。"
  Source="System"
  StackTrace:
        System.IO.Ports.SerialPort.ReadTo(String value)
        Ex13_01.Form1.button2_Click(Object sender, EventArgs e) 位置 F:\数据库开发\SQL数据库\各种练习\Ex13_01\Ex13_01\Form1.cs:行号 32
        System.Windows.Forms.Control.OnClick(EventArgs e)
        System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
        System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
        System.Windows.Forms.Control.WndProc(Message& m)
        System.Windows.Forms.ButtonBase.WndProc(Message& m)
        System.Windows.Forms.Button.WndProc(Message& m)
        System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
        System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
        System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
        System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
        System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
        System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
        Ex13_01.Program.Main() 位置 F:\数据库开发\SQL数据库\各种练习\Ex13_01\Ex13_01\Program.cs:行号 17
        System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
        Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
        System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        System.Threading.ThreadHelper.ThreadStart()