簡體   English   中英

找不到來自 Zebra SDK 的`UsbConnection()` class

[英]Can't find `UsbConnection()` class from Zebra SDK

我通過 NuGet 安裝了 Zebra.Printer.SDK 並using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; . 我正在嘗試通過 USB 連接到我的打印機。 在示例中,他們執行以下操作:

} else {
   printerConnection = new UsbConnection(selectedItem.Address);
}

我在我的應用程序中嘗試了同樣的方法。 但我找不到UsbConnection class。 我需要添加其他依賴項嗎?

SKD 參考

SDK 安裝包含示例

如果您正確安裝了 Nuget 庫,您應該擁有運行應用程序所需的庫依賴項。 對於 usb 通信,您需要允許接口通信的 usb dll。 請從這個鏈接下載 Multiplatform SDK,它有一個名為 PC -.NET 的文件夾,點擊它,然后 go 到“C:\Program Files\Zebra Technologies\link_os_sdk\PC-.demos\v2.15.2634 -desktop\Source”,它有一個完整的 Visual Studio 項目,您可以立即安裝和運行。 此示例代碼滿足您的所有需求,包括用於 usb 通信的 dll。

對於 USB class API 文檔,請點擊以下鏈接。

Zebra.Sdk.Comm 命名空間

https://techdocs.zebra.com/link-os/2-14/pc_net/content/html/85823b27-9fa5-7681-c212-8e536f601bbe.htm

USB連接 Class

https://techdocs.zebra.com/link-os/2-14/pc_net/content/html/ab837158-704b-90f5-f754-c05091f89421.htm

公共 UsbConnection(字符串符號名稱)

參數

symbolicName 類型:System.String

UsbDiscoverer.GetZebraUsbPrinters() 成員 function 返回的設備的 USB 符號名稱。

符號名稱示例:\?\usb#vid_0a5f&pid_016e#zq520r#{28d78fad-5a12-11d1-ae5b-0000f803a8c2}

private void SendZplOverUsb(string symbolicName) {
 // Instantiate connection for ZPL USB port at given address/symbolicName
    Connection thePrinterConn = new UsbConnection(symbolicName);

    try {
        // Open the connection - physical connection is established here.
        thePrinterConn.Open();

        // This example prints "This is a ZPL test." near the top of the label.
        string zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

        // Send the data to printer as a byte array.
        thePrinterConn.Write(Encoding.UTF8.GetBytes(zplData));
    } catch (ConnectionException e) {
        // Handle communications error here.
        Console.WriteLine(e.ToString());
    } finally {
        // Close the connection to release resources.
        thePrinterConn.Close();
    }
}

Zebra Link-OS - C# 查看示例代碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM