XmlPrinting with .Net core - Zebra.Printer.SDK not working (Builder not correctly implemented)
I designed a label with Zebra Designer for Developers. I could test print it from there on a ZT411 300dpi, with default values for the variables.
I am now trying to print it from .Net 5 code, without success.
I tried :
Create a console application in .Net 5.
Install Nuget package Zebra.Printer.SDK (2.15.2634)
Copy-paste the following code example: https://techdocs.zebra.com/link-os/2-14/pc_net/content/html/8026e23d-26…
Create the file XmlPrinterExampleTemplate.zpl and add the ZPL code (see comment in example)
Change the IP address to use the correct one.
When I start the program, the first call to XmlPrinter.Print works (it only logs to the console) but the other two give me the following error:
System.ArgumentException: Builder not correctly implemented
at Zebra.Sdk.Comm.Internal.ConnectionBuilderInternal.Build(String descriptionString)
at Zebra.Sdk.Printer.CsvPrinter.OpenConnection(String destinationDevice)
at Zebra.Sdk.Printer.CsvPrinter.Print(String destinationDevice, Stream sourceDataStream, String templateFilename, String defaultQuantityString, Stream outputDataStream, Boolean verbose)
at Zebra.Sdk.Printer.XmlPrinter.Print(String destinationDevice, Stream sourceDataStream, String templateFilename, String defaultQuantityString, Stream outputDataStream, Boolean verbose)
I tried several IP address formats (« 220.127.116.11 », « 18.104.22.168:9100 », « TCP:22.214.171.124 », et « TCP:126.96.36.199:9100 ») but always get the same error.
I found this doc about ConnectionBuilder: https://techdocs.zebra.com/link-os/2-15/pc_net/content/html/ba1a1ca6-59…
After I copy-pasted the method "SendZplOverTcp" I get the compile-time error "Error CS0103 The name 'ConnectionBuilder' does not exist in the current context"
It seems the ConnectionBuilder class is not publicly accessible in the 2.15 version of the nuget package.
When I downgrade to version 2.14.1989, I get a warning and another compile-time error.
Warning NU1701 Package 'Zebra.Printer.SDK 2.14.1989' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.
Error NETSDK1149 SdkApi_Desktop.dll cannot be referenced because it uses built-in support for WinRT, which is no longer supported in .NET 5 and higher. An updated version of the component supporting .NET 5 is needed. For more information, see https://aka.ms/netsdk1149
The compilation error was fixed by downgrading the project to .Net Core 3.1
With version 2.14 of the package and .Net core 3.1 I could print "This is a ZPL test" with the printer. However, the XmlPrinterExample is still not working; I got errors regarding a dependency with CsvHelper. I managed to find a compatible version of CsvHelper and I then get the following error :
Exception thrown: 'System.IO.FileNotFoundException' in SdkApi_Core.dll
I tried to use .Net Framework 4.7.2 and had the same error about SdkApi_Core.dll
As the nuget package was definitely not working, I tried downloading the SDK from here: https://www.zebra.com/fr/fr/support-downloads/printer-software/link-os-… (Windows version)
Unfortunately, in the lib directory, there is nothing else than the nuget package (the one that I can't make work)
There is also a demo included in the SDK, in C:\Program Files\Zebra Technologies\link_os_sdk\PC-.NET\v2.15.2634\demos-desktop\Source
This demo contains multiple examples but I don't see an example for XML printing with the label I designed in Zebra Designer.
I feel stuck. Can someone help me print my label with Xml printing ?
Other acceptable solutions :
- Something else than Xml printing that would let me print a label with variables
The whole implementation of the Link-OS SDK for PC-.NET is built for the .NET Framework 4.7 (or higher). The .NET 5 & the .NET 6 are the evolution of the .NET Core 3.1, which is not supported by the Link-OS SDK for PC-.NET from the beginning.
Please change your .NET project to a .NET Framework 4.7 or 4.8 based project.