title: C# .NET serial port connects, doesn't read or write
body: <p>I'm using C# and .NET 4.5, with the Visual Studio 2012 compiler/IDE to open and interact with a serial port.  My code is designed to connect to the QSB quadrature-to-USB converter from US Digital.  </p>
  
  <p>Here is the code that I'm using to open the port and connect.</p>
  
  <pre><code>this.Port = new SerialPort();
  
  this.Port.BaudRate = 230400;
  this.Port.PortName = "COM9";
  this.Port.Parity = Parity.None;
  this.Port.Handshake = Handshake.None;
  this.Port.DataBits = 8;
  this.Port.StopBits = StopBits.One;
  
  this.Port.Open();
  </code></pre>
  
  <p>Setting a breakpoint immediately after this.Port.Open() allows me to verify that the serial port is indeed connected.  In another section of code, the following is called in response to a button push:</p>
  
  <pre><code>this.Port.WriteLine("W168");
  </code></pre>
  
  <p>This command *should cause my hardware to spin a motor, and in fact it does if I send the command using Putty, or using a Python script that I wrote (both using exactly the same settings as the C# code does).  Yet nothing happens.  I can open the port in Putty or Python and execute the command with the expected results, and then run my C# code and nothing happens.</p>
  
  <p>Am I missing something C# specific that prevents this from working?</p>
  
  <p>For what it's worth, here is my working Python code:</p>
  
  <pre><code>ser = serial.Serial("COM9", 230400, timeout=1)
  ser.write(b"W168\n")
  </code></pre>
  
  <p>Link to pySerial documentation: <a href="http://pyserial.sourceforge.net/pyserial_api.html#classes" rel="nofollow">http://pyserial.sourceforge.net/pyserial_api.html#classes</a></p>
  
  <p>Default values for fields mentioned in the C# code but not mentioned in the python call above are:</p>
  
  <ul>
  <li>bytesize = 8</li>
  <li>parity = none</li>
  <li>stopbits = one</li>
  <li>xonxoff = false</li>
  <li>rtscts = false</li>
  <li>dsrdtr = false</li>
  </ul>