Я пытаюсь написать .net 8 C# библиотека класса, чтобы можно было взаимодействовать с PrintTart. Тем не менее, я не могу подключиться к принтеру, а переменная устройств ниже - null. < /P>
код: < /p>
Код: Выделить всё
public class EpsonPosPrinter : IPosPrinter, IDisposable
{
private PosPrinter _printer;
private const string PrinterName = "Printer"; // Replace with your printer's name
public async Task InitializeAsync()
{
// Find the first available POS printer that matches the name.
//var selector = PosPrinter.GetDeviceSelector();
string selector = PosPrinter.GetDeviceSelector(PosConnectionTypes.All);
var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(selector);
if (devices.Count > 0)
{
var deviceId = devices[0].Id;
_printer = await PosPrinter.FromIdAsync(deviceId);
if (_printer != null)
{
await _printer.ClaimPrinterAsync();
//await _printer.EnableAsync();
Console.WriteLine("Printer initialized successfully.");
}
}
else
{
Console.WriteLine("No POS printers found.");
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ss-library
Мобильная версия