Problem with Windows 10, VS2015 System.UnauthorizedAccessException

I am using VS2015 under Win10.

I have an old application that has just appeared on this platform. I need to open the serial port inside the application. Here is a snippet of code

_port = new SerialPort (port, 19200, Parity.None, 8, StopBits.One);
_port.DtrEnable = false;
_port.Handshake = Handshake.None;
_port.RtsEnable = false;
_port.ReadTimeout = 150;
_port.WriteTimeout = 150;

try {
    _port.Open ();
}
catch (Exception e) {
    TryTrace (TraceEventType.Error, 0, 
              String.Format("Exception opening port: {0}", e.Message));
    throw;
}

This is a throw System.UnauthorizedAccessException, Access denied exception .

I open this application using launch as administrator.

Then I created a test application, just try to open the same serial port. which works great.

I tried switching the UAC, this does not seem to make any difference.

Has anyone got an idea?

Many thanks

+4
source share

Source: https://habr.com/ru/post/1617856/


All Articles