Hi im trying to simply print "Hello World" but I get an error "The value of the 'DevicePath' property must be defined by the service object before Open() can be called." and it points to this line printer.Open();
I am using .NET 4.8 and I have referenced the Microsoft.PointOfService; already. TIA.
using Microsoft.PointOfService;
using System;
namespace PrinterTest
{
class Program
{
static void Main(string[] args)
{
PosExplorer explorer = new PosExplorer();
DeviceCollection devices = explorer.GetDevices(DeviceType.PosPrinter);
Console.WriteLine("Checking for connected POS Printers...");
foreach (DeviceInfo device in devices)
{
if (device.ServiceObjectName.IndexOf("TM-U220B", StringComparison.OrdinalIgnoreCase) >= 0)
{
Console.WriteLine("TM-U220B printer is connected!");
PosPrinter printer = (PosPrinter)explorer.CreateInstance(device);
printer.Open();
printer.Claim(1000);
printer.DeviceEnabled = true;
printer.PrintNormal(PrinterStation.Receipt, "Hello World\n");
//printer.Cut(PosPrinterCutType.FullCut);
printer.Release();
printer.Close();
Console.WriteLine("Printed 'Hello World' successfully.");
break;
}
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}