0

I have problem with barcode scanner randomly disconnecting from serial port so I want to try using newer version of System.IO.Ports.SerialPort which is available via NuGet package.

.NET Framework 4.8.0 SerialPort is version 4.0.0.0, NuGet SerialPort is version 6.0.0.0. I was thinking about assembly redirect, but here is stated, that assembly redirect is not for this purpose.

How to use newer version of SerialPort?

Ondřej
  • 1,645
  • 1
  • 18
  • 29
  • 1
    That's pointless, the nuget package is merely a shim assembly. It does not contain any code and simply [TypeForwardedTo] to the SerialPort class you already used. Try to get ahead by diagnosing the problem correctly, serial ports are not connection oriented so you can't "randomly disconnect". Not properly selecting the Handshake property value is a very common oversight. – Hans Passant Mar 18 '22 at 15:31
  • If the scanner is connected via USB, it is likely that Plug and Play Removal/Arrival notifications have occurred due to electrostatic discharge noise or the like. Any version of the serial port library will not support the workaround. You will need to detect and deal with it using other features like these, for example. [A USB Library to Detect USB Devices](https://www.codeproject.com/Articles/60579/A-USB-Library-to-Detect-USB-Devices), [Check for device change (add/remove) events](https://stackoverflow.com/q/16245706/9014308), [Detect serial...](https://stackoverflow.com/q/4199083/9014308) – kunif Mar 19 '22 at 03:39
  • To be precise: Reader randomly disconnects and immediately connects again, I have logging system and DsrChanged is recorded. – Ondřej Mar 19 '22 at 16:04

0 Answers0