Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Unable to open Serial Port 'SerialPortStream' by Jason Curl - System.UnauthorizedAccessException

I have the following code

    public void COMPortSelectionMade(SerPortName portNamePicker)
        if (Device.RuntimePlatform == Device.UWP)
            serialPort = new RJCP.IO.Ports.SerialPortStream(portNamePicker.PortName);

// serialPort.PortName = portNamePicker.PortName;
serialPort.ReadTimeout = 500;
serialPort.WriteTimeout = 500;
serialPort.Handshake = RJCP.IO.Ports.Handshake.None;

            if (!(serialPort.IsOpen == true))



The port Name is either COM1, COM2, COM4 or COM6 - all are unused, and COM4 is a device I physically connect - so it is for sure not being used by any other device.

I set a breakpoint at the if (!(serialPort.IsOpen == true)) - so this is the first time that code is executed.

I get an error System.UnauthorizedAccessException: 'Access Denied: COM4'

The port is not open, it fails on the first pass.

Any ideas what I can try next?

Thanks for any help.



  • RSalRSal CAMember ✭✭

    I used Process Explorer, and verified there are no processes using the servrice 'usbser' used by the USB virtual serial port.

Sign In or Register to comment.