[Mono-list] Problem in System.IO.Ports.SerialPort.ReadExisting()?

Tom Opgenorth opgenorth at gmail.com
Wed Dec 12 11:00:49 EST 2007


Hello all,

I'm using Mono 1.2.6 preview 4.  I have a WinForms app that I'm
developing in VS2008, targetting .NET 2.0.  One of the things I'm
doing is enumerating over the serial ports, looking for a a piece of
hardware that might be connected.

When I try to run the program using Mono,   I get the following error:
mono --debug ChronyReader.exe

Unhandled Exception: System.NullReferenceException: Object reference
not set to an instance of an object
  at (wrapper managed-to-native)
System.IO.Ports.WinSerialStream:ClearCommError
(int,System.IO.Ports.CommStat&)
  at System.IO.Ports.WinSerialStream.get_BytesToRead () [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\WinSerialStream.cs:396
  at System.IO.Ports.SerialPort.get_BytesToRead () [0x00006] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\SerialPort.cs:167
  at System.IO.Ports.SerialPort.ReadExisting () [0x00006] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\SerialPort.cs:641
  at (wrapper remoting-invoke-with-check)
System.IO.Ports.SerialPort:ReadExisting ()
  at Opgenorth.Reloading.Chrony.Communications.SerialChronyPort.Open
() [0x00000]
  at Opgenorth.Reloading.Chrony.Communications.SerialChronyPort.Ping
() [0x00000]
  at Opgenorth.Reloading.Chrony.Communications.ActiveSerialPortLister.GetList
() [0x00000]
  at Opgenorth.Reloading.ChronyReader.ChronyReaderForm.ListAvailablePorts
() [0x00000]
  at Opgenorth.Reloading.ChronyReader.ChronyReaderForm..ctor () [0x00000]
  at (wrapper remoting-invoke-with-check)
Opgenorth.Reloading.ChronyReader.ChronyReaderForm:.ctor ()
  at ChronyReader.Program.Main () [0x00000]	

Note that in this case there is nothing attached to any serial ports.

Has anybody else run into this?  Should I report a bug?

Thanks for any help.


More information about the Mono-list mailing list