❔ How to resolve System.UnauthorizedAccessException when a serial port is open but already in use
Hi there, I'm sorry for this newbie request but I looked for any solution on SO with no avail.
I have a simple .NET 4.5 software that use a Serial port to connect with a device. In the first form there a combobox with all serial port but even if I checked in advance if the portName is open, if the port is already in use the software there will be an infinite loop of Error in Serial Configuration due to System.UnauthorizedAccessException.
Do you have any suggestions? Thanks in advance.
4 Replies
Stack Overflow
SerialPort UnauthorizedAccessException
Occasionally some of my integration tests are failing with the above message. I'm using the code below to ready the port.
for(int i = 0; i < 5; i++)
{
t...
This should explain it fairly well
Thanks for your reply 🙏 .
My difficulties is about the user that must choose the serial port from a list of all available ports before the software start and sometimes choose a port that is already in use by other software.
I think that I need a some check of that port before my program start but isOpen is not enough.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.