不能声称PosPrinter
我有一个TM-T20爱普生,我正在使用此代码尝试打印:“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.
样本申请的打印屏幕: