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…
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”
Why use that old thing in a .NET application? Why not work directly with the COM port using the .NET API?
@JohnSaunders would you please suggest better .NET API for communication with COM port
See SerialPort class. And don’t ever use any VB6 stuff with .NET. It’s all over a decade old!