Cannot get USB connected GX420d Status or Errors


I have a .net 5.0 project that uses a USB connected GX420d zebra printer to print tickets.
I'm trying to access to the printer status/errors with no success.
I've tried to use windows ManagementObjectSearcher to access the printer properties:

ManagementObjectSearcher wmiQuery = new ManagementObjectSearcher("root\\CIMV2");
wmiQuery.Query = new ObjectQuery(string.Format("SELECT * FROM Win32_Printer where Name = \"{0}\"", _printerName));

The printer is found but all the properties i'm interested in ("DetectedErrorState", "PrinterState" etc..) never change value.

I've also tried to use code from the Developer Demo to create an USB connection but the libraries are designed for .net framework 4.7 and not .net 5.0.

printerConnection = new DriverPrinterConnection(_printerName);

when I try to open a connection I get an exeption that says that no printer with such name is installed.
I would like any insight on how I could read the printer status or on what i'm doing wrong.

Submitted by SSi1 on January 20, 2022 Permalink

The best approach at this moment is to switch the .NET 5 project back to .NET Framework 4.7, so that you can use the Link-OS SDK for PC .NET. Otherwise, a lot of issues could come out as we have not done much research on the .NET 5 with regard to the USB connection to the printers.