Если я запускаю мой следующий код, который я создал с SharpDevelop:Что я могу сделать против следующих # SerialPort Ошибки C
SerialPort serial = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
void sendMsg_Click(object sender, EventArgs e)
{
serial.Open();
serial.WriteLine(textBox1.Text);
serial.Write(new byte[] {0x0A, 0xE2, 0xFF}, 0, 3);
serial.Close();
}
Ниже исключение появляется при выполнении кода:
Исключение составляет следующие:
System.IO.IOException: Falscher Parameter.
bei System.IO.Ports.InternalResources.WinIOError
bei System.IO.Ports.SerialStream.EndWrite
bei System.IO.Ports.SerialStream.Write
bei System.IO.Ports.SerialPort.Write
bei System.IO.Ports.SerialPort.WriteLine
bei Chat_via_RS232.MainForm.sendMsg_Click in c:\Users\admin\Documents\SharpDevelop Projects\Latias.eu IT\Chat via RS232\MainForm.cs:Zeile 35
bei System.Windows.Forms.Control.OnClick
bei System.Windows.Forms.Button.OnClick
bei System.Windows.Forms.Button.OnMouseUp
bei System.Windows.Forms.Control.WmMouseUp
bei System.Windows.Forms.Control.WndProc
bei System.Windows.Forms.ButtonBase.WndProc
bei System.Windows.Forms.Button.WndProc
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc
bei System.Windows.Forms.NativeWindow.DebuggableCallback
bei System.Windows.Forms.Application.ComponentManager.FPushMessageLoop
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop
bei System.Windows.Forms.Application.Run
bei Chat_via_RS232.Program.Main in c:\Users\admin\Documents\SharpDevelop Projects\Latias.eu IT\Chat via RS232\Program.cs:Zeile 24
Может кто-нибудь мне помочь.
С уважением
Лала
Каково точное фактическое значение 'textBox1.Text', когда происходит ошибка? – Dai
Какой из них «MainForm.cs: Zeile 35»? – Fildor
Он уже говорит вам: «Неверный параметр». Если бы вы добавили номера строк или сказали бы нам, где он разбился (это говорит строка 35, но мы не знаем, какая из них), вы могли бы получить дополнительную помощь. Но вы должны решить эту проблему самостоятельно. – Matthias247