Printing to a ZQ521 from Xamarin Forms via Bluetooth

// Expert user has replied.
N Nathan Perrin 2 years 11 months ago
199 3 0

I am having trouble printing to a Zebra ZQ521 from a Xamarin Forms 3.4 app via Bluetooth from a Zebra TC20. I’m using the Zebra.Printer.SDK NuGet package version 2.15.2634.

When I call Zebra.Sdk.Printer.XmlPrinter.Print(), the Bluetooth symbol on the printer’s LCD is displayed, then after a few seconds it blinks and goes out.

The following exception is raised:
Zebra.Sdk.Comm.ConnectionException: Could not open connection
at Zebra.Sdk.Comm.MultichannelBluetoothConnection.Open () [0x00034] in :0
at Zebra.Sdk.Printer.CsvPrinter.OpenConnection (System.String destinationDevice) [0x00007] in :0
at Zebra.Sdk.Printer.CsvPrinter.Print (System.String destinationDevice, System.IO.Stream sourceDataStream, System.String templateFilename, System.String defaultQuantityString, System.IO.Stream outputDataStream, System.Boolean verbose) [0x00160] in :0
at Zebra.Sdk.Printer.XmlPrinter.Print (System.String destinationDevice, System.IO.Stream sourceDataStream, System.String templateFilename, System.String defaultQuantityString, System.IO.Stream outputDataStream, System.Boolean verbose) [0x00038] in :0

I have verified that the correct Bluetooth address is being passed to the Print() method.

Please Register or Login to post a reply

3 Replies

S Steven Si

By just looking at the exception trace, it's difficult to figure out what could went wrong. The source code snippet would be helpful.

Have you tried the XamarinDevDemo project, which comes with the Link-OS SDK release package. The path of the XamarinDevDemo is: link_os_sdk\PC-.NET\v2.15.2634\demos-xamarin\Source. It's been verified that the XamarinDevDemo works with TC20 Bluetooth. Take a look at the code that uses Bluetooth in the XamarinDevDemo project.

N Nathan Perrin

How do you build this solution? I cannot find a .sln file and tried opening the project file in the XamarinDevDemo folder but this would not build. I updated the NuGet references and it builds OK but cannot run as its output type is Class Library. Am I missing something obvious here?

S Steven Si

You simply create a new solution named as XamarinDevDemo in Visual Studio. This will create a top level folder called XamarinDevDemo and its XamarinDevDemo.sln file, etc. Within this newly created XamarinDevDemo solution, you simply add the 4 projects that come with the SDK release, i.e. XamarinDevDemo, XamarinDevDemo.Android, XamarinDevDemo.iOS and XamarinDevDemo.WPF, through Visual Studio. Then you should be able to compile.

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