4

我有一个 TM-T20 Epson,我正在使用此代码尝试打印:“Hello Printer”消息,并且我一直在跟踪 PosPrinter 的一些特性:

public void ImprintHelloPrinter()
        {
            //The Explorer
            PosExplorer explorer = new PosExplorer();

            ////Get the device by its type LOGICAL NAME
            DeviceInfo device = explorer.GetDevice(DeviceType.PosPrinter, "T20PRINTER");

            //Create an instance
            PosPrinter oposPrinter = (PosPrinter)explorer.CreateInstance(device);

            //Opening 
            MessageBox.Show(@"Statue : " + oposPrinter.State.ToString());
            oposPrinter.Open();
            MessageBox.Show(@"Statue : " + oposPrinter.State.ToString());

            //Checking if its really the printer
            MessageBox.Show(@"Description : " + oposPrinter.DeviceDescription);


            MessageBox.Show(@"Check Claimed : " + oposPrinter.Claimed.ToString());
            oposPrinter.Claim(10000); //Here is My Exception 

            //Enabeling device
            oposPrinter.DeviceEnabled = true;

            //normal print
            oposPrinter.PrintNormal(PrinterStation.Receipt, "Hello Printer");
        }

一切正常,我检查了它是否是正确的打印机,它打开并且没有声明,但是当我尝试声明它时,我有以下异常:

Method ClaimDevice threw an exception.  Attempt was made to perform an illegal 

or unsupported operation with the device, or an invalid parameter value was used.

即使在示例应用程序文件夹 ( C:\Program Files\Microsoft Point Of Service\SDK\Samples\Sample Application ) 中随Microsoft Point Of Service SDK提供的示例应用程序中,我也可以找到我的打印机,打开它,但是当我声称我有这个错误信息:

POSControlException ErrorCode(Illegal) ExtendedErrorCode(10002) occurred:
Method ClaimDevice threw an exception.  Attempt was made to perform an illegal
 or unsupported operation with the device, or an invalid parameter value was 
used.

示例应用程序的打印屏幕:

在此处输入图像描述

4

1 回答 1

0

该错误是因为您配置了错误的端口。
在我的例子中,我使用连接到硬件 NPort 5110 的型号 FP-81 II,我将端口配置为 9100。

NPort 配置

我希望能帮助你。

于 2019-07-26T13:17:42.650 回答