1

I used microsoft com control 6.0 in the application for sending data to the led control

         MSComm1.EOFEnable = True
        MSComm1.SThreshold = 100
        MSComm1.InputLen = 0
        MSComm1.RThreshold = 1
        MSComm1.InBufferCount = 0
        MSComm1.OutBufferCount = 0
        MSComm1.NullDiscard = False
        MSComm1.CommPort =1
        MSComm1.PortOpen = True <-Getting exception to this line
        ......

I am geting Exception from HRESULT: 0x800A1F45 .Why does this port is not opening . When i run it through vb6 i doesnt get error ...Anybody can help me...

Coder Guru
  • 513
  • 3
  • 18
  • 37
  • Why use that old thing in a .NET application? Why not work directly with the COM port using the .NET API? – John Saunders Nov 27 '11 at 09:30
  • @JohnSaunders would you please suggest better .NET API for communication with COM port – Coder Guru Dec 27 '11 at 05:50
  • 1
    See [SerialPort class](http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx). And don't _ever_ use any VB6 stuff with .NET. It's all over a decade old! – John Saunders Dec 27 '11 at 14:48

1 Answers1

1

Error 800A1F45 usually means the port is in use by another application.

You can decode an HRESULT according to this Wikipedia article. For 0x800A1F45, you'll find:

  • The third bit is 0, so it's a Microsoft error
  • The facility bits are hex 0xA, or decimal 10, which according to the MSDN list means "Control"
  • The error code bits are hex 0x01F45, or decimal 8005. According to the error list for the MSComm control that means "Port already open"
Andomar
  • 232,371
  • 49
  • 380
  • 404