我有一台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.
示例应用程序的打印屏幕: