Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to the port 'COM1' is denied

Tags:

asp.net

I am trying to open the COM1 port but I am getting this error message "Access to the port 'COM1' is denied". I am writing a program for sending SMS via .NET. I expect there could be an error, but the error "Access denied" should not be arisen. Please give me any solution. If port requires any access privileges then how can I do that?

like image 791
user140003 Avatar asked Jul 20 '09 13:07

user140003


People also ask

How do I open a COM1 port?

Right-click on Communications Port (COM1) and select Properties. In the Properties window, click on the Port Configuration tab and then click on Port Setting. For the Port Number field, use the pull-down menu to select COM2 for your Native COM Port and click OK.


2 Answers

First, make sure the serial port exists. Check the Device Manager; right-click on My Computer, select "Manage" from the context menu, select "Device Manager", expand "Ports Com & LPT". If Com1 is not listed, you will need to enable it in the BIOS.

If COM1 is there, then another program has left it open. Access to COM1 is exclusive; only one program can have it open at a time. Fax software or a modem could have it open, or you could have left it open yourself.

This is easy to do. If you work on a program that opens the port and forget to close it, or if an error occurs and the program terminates without closing the port, this is the message you will get the next time you try to open COM1. Only the program that opened the port can close it. "Catch" or "Finally" blocks are good places to close the port and prevent this.

like image 50
R Ubben Avatar answered Sep 21 '22 12:09

R Ubben


There's probably something else using COM1 (auto sync programs tend to be quite bad at grabbing COM ports as soon as they become available).

Try downloading PortMon and it will tell you exactly what's using the port.

like image 39
Vicky Avatar answered Sep 19 '22 12:09

Vicky