-->

can't claim the PosPrinter

2020-04-08 18:26发布

问题:

I have a TM-T20 Epson, I'm using this code to try to print : "Hello Printer" Message, and i keep tracking of some proprieties of the 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");
        }

Everything went OK, i checked that it is the right Printer and it opened and its not claimed, but when i try to Claim it i have the following Exception :

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.

Even in the Example application provided with the Microsoft Point Of Service SDK in the Sample Application Folder (C:\Program Files\Microsoft Point Of Service\SDK\Samples\Sample Application), i can find my printer, open it, but when i Claim it i have this error message :

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.

Print Screen Of The Sample Application :

回答1:

The error is because you have bad port configurated.
In my case, I use model FP-81 II connected to hardware NPort 5110 where I was configure port to 9100.

I hope help you.