[Mono-bugs] [Bug 499637] New: SerialPort.BytesToRead throws NullReferenceException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 30 01:54:14 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=499637


           Summary: SerialPort.BytesToRead throws NullReferenceException
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: x86-64
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: zibalas at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10)
Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)

'm trying to run a very simple SerialPort test app (see the code below) on
Windows XP. Applicaion was compiled using VS.NET 2008 this is exception i get
when i call SerialPort.BytesToRead (P.S. Application works fine using MS .NET):

System.NullReferenceException: Object reference not set to an instance of an
obj
ect
  at (wrapper managed-to-native) System.IO.Ports.WinSerialStream:ClearCommError
(int,uint&,System.IO.Ports.CommStat&)
  at System.IO.Ports.WinSerialStream.get_BytesToRead () [0x00000]
  at System.IO.Ports.SerialPort.get_BytesToRead () [0x00000]
  at (wrapper remoting-invoke-with-check)
System.IO.Ports.SerialPort:get_BytesTo
Read ()
  at PortGrindTest.Program.ThreadFunction () [0x00000]

Reproducible: Always

Steps to Reproduce:
1. Open serial port
2. Call SerialPort.WriteLine("smth")
3. Call SerialPort.Readline()
4. Call SerialPort.BytesToRead
Actual Results:  
System.NullReferenceException: Object reference not set to an instance of an
obj
ect

Expected Results:  
Int BytesToRead

Actual code I'm using:

SerialPort port = new SerialPort("COM6");
                    port.ReadTimeout = 2000;
                    port.WriteTimeout = 1000;
                    Console.WriteLine("Thread {0} opened port",
Thread.CurrentThread.ManagedThreadId);
                    lock (this)
                    {
                        port.Open();
                    }
                    try
                    {
                        port.WriteLine("ATE");
                        port.WriteLine("AT");
                        do
                        {
                            string line = port.ReadLine();
                            Console.WriteLine("Received {0}", line);
                        } while (port.BytesToRead != 0);
                    }
                    catch (TimeoutException e)
                    {
                        Console.WriteLine("Thread {0} {1} {2}",
Thread.CurrentThread.ManagedThreadId, freePort.Name, e.Message);
                    }

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list