C
C#2y ago
matcfs

❔ 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
Buddy
Buddy2y ago
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...
Buddy
Buddy2y ago
This should explain it fairly well
matcfs
matcfsOP2y ago
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.
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server