LinkOS Multiplatform SDK Null ref exception

// Expert user has replied.
R Rob Deans 6 months 3 weeks ago
57 2 0

Using latest stable package on NuGet, 2.16.2905

Encountering an issue where a null reference exception occurrs within the SDK. Specifically it occurrs in Zebra.SDK.Comm in DriverPrinterConnection with the method BytesAvailable(). Specifically line 176, ReadFromPrinter() is returning null and there is nothing in place to ensure that the value is not null.

 

Currently
 


byte[] temporaryReadBuffer = ReadFromPrinter();
if (temporaryReadBuffer.Length < 0)
{
	throw new ConnectionException("Failed to read from the USB port: " + PrinterName);
}

 

Suggesting change

 


byte[] temporaryReadBuffer = ReadFromPrinter();
if (temporaryReadBuffer == null)
{
	throw new ConnectionException("Failed to read from the USB port: " + PrinterName);
}
	
Please Register or Login to post a reply

2 Replies

S Steven Si

Thanks for pointing this out. It should have been fixed in Zebra.Printer.SDK v3.0.3271, which is available on NuGet.

S Shifali J

i am using vb.net 4.8 version but zebra printer sdk isnot supporting my version so i tried installing its older version it got installed but while importing package to my code it gives the error type is not defined  
   Private Function ConvertZPLToImage(ByVal zplCommand As String) As Image
      Try
          ' Initialize the SDK
          Dim sdk As New ZebraPrinterSdk()

          ' Create a ZPL renderer
          Dim renderer As New ZplRenderer()

          ' Render the ZPL command to an image
          Dim imageBytes As Byte() = renderer.Render(zplCommand)

          ' Convert the image bytes to an Image object
          Using ms As New MemoryStream(imageBytes)
              Dim img As Image = Image.FromStream(ms)
              Return img
          End Using
      Catch ex As Exception
          ' Handle any exceptions
          MessageBox.Show("Error converting ZPL to image: " & ex.Message)
          Return Nothing
      End Try
  End Function

CONTACT
Can’t find what you’re looking for?