不能声称PosPrinter

时间:2014-03-15 23:19:47

标签: c# printing pos-for-.net

我有一台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>中的 Microsoft Point of Service SDK 提供的示例应用程序中也是如此文件\ Microsoft服务点\ SDK \ Samples \示例应用程序),我可以找到我的打印机,打开它,但当我声明它时,我有这样的错误消息:

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.

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

enter image description here

1 个答案:

答案 0 :(得分:0)

该错误是因为您配置的端口错误。
就我而言,我使用的是连接到硬件NPort 5110的FP-81 II型,其中我将端口配置为9100。

NPort configuration

希望对您有所帮助。