首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Zebra SDK中找不到` `UsbConnection()`类

在Zebra SDK中找不到` `UsbConnection()`类
EN

Stack Overflow用户
提问于 2020-05-26 16:43:42
回答 1查看 855关注 0票数 0

我通过NuGet安装了Zebra.Printer.SDK,并包含了using Zebra.Sdk.Comm;using Zebra.Sdk.Printer;。我正在尝试通过USB连接到打印机。在该示例中,它们执行以下操作:

代码语言:javascript
复制
} else {
   printerConnection = new UsbConnection(selectedItem.Address);
}

我在我的应用程序中尝试了相同的方法。但是我找不到UsbConnection类。我需要添加额外的依赖项吗?

The SKD reference

包含示例的SDK Installation

EN

回答 1

Stack Overflow用户

发布于 2020-05-27 01:46:37

如果正确安装了Nuget库,则应该具有运行应用程序所需的库依赖项。对于usb通信,您需要允许接口通信的usb dll。请从该Link下载多平台开发工具包,它有一个名为PC -.NET的文件夹,单击它,然后转到“C:\Program Files\Zebra Technologies\link_os_sdk\PC-.NET\v2.15.2634\demos-desktop\Source”,”它有一个完整的Visual Studio项目,您可以立即安装和运行。这个示例代码包含了您需要的所有内容,包括用于usb通信的dll。

有关USB类API文档,请访问以下链接。

Zebra.Sdk.Comm命名空间

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

UsbConnection类

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

公共UsbConnection(string symbolicName)

参数

symbolicName类型: System.String

由UsbDiscoverer.GetZebraUsbPrinters()成员函数返回的设备的USB符号名称。

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

代码语言:javascript
复制
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# view Sample Code

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62017991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档