jcurl / RJCP.DLL.SerialPortStream

SerialPortStream is an independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability. Default branch is 2.x and now has support for Mono with help of a C library.
Microsoft Public License
628 stars 197 forks source link

Access Denied: COM3 #38

Closed dennisai closed 6 years ago

dennisai commented 6 years ago

Hi, I am using Serial Port Stream on .NET 4.5.1 / Windows 10 Pro x64 as a replacement for the default SerialPort implementation in the .NET Framework. However, when I go to open my port, I get an access denied exception.

 public bool IsConnected
 {
     get {
         if (!isConnected.HasValue) {
            mutex.WaitOne();
            if (!serialPortStream.IsOpen) { serialPortStream.Open(); } // Exception thrown here.
            ...
         }
    }
}

The stack trace is as follows.

 at RJCP.IO.Ports.Native.WinNativeSerial.WinIOError() in c:\Users\jcurl\Documents\Programming\HELIOS\serialportstream\code\Native\WinNativeSerial.cs:line 937
 at RJCP.IO.Ports.Native.WinNativeSerial.Open() in c:\Users\jcurl\Documents\Programming\HELIOS\serialportstream\code\Native\WinNativeSerial.cs:line 845
 at RJCP.IO.Ports.SerialPortStream.Open(Boolean setCommState) in c:\Users\jcurl\Documents\Programming\HELIOS\serialportstream\code\SerialPortStream.cs:line 245

Any idea why this might be happening? The implementation I was using before with the SerialPort from .NET Framework was working fine, and I can open the port using Advanced Serial Port Monitor with no problems.

This is the serial port in Device Manager. serialport

dennisai commented 6 years ago

Just to report, I have tried to upgrade to .NET 4.6.2 but to no avail. Same problem.

dennisai commented 6 years ago

Nevermind, this issue came from something else in my code. Everything works great, and way better than the default SerialPort implementation!