C# can';Don’不要认领那台打印机

C# can';Don’不要认领那台打印机,c#,printing,pos-for-.net,C#,Printing,Pos For .net,我有一个TM-T20爱普生,我正在使用此代码尝试打印:“Hello Printer”消息,我一直在跟踪PosPrinter的一些特性: public void ImprintHelloPrinter() { //The Explorer PosExplorer explorer = new PosExplorer(); ////Get the device by its type LOGICAL NAME

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


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


我希望能帮助你。

oposPrinter.Claim(10000)//这里是我的例外。如果我已经为打印机/端口安装了打印机驱动程序,那么我使用POS for.Net会得到一些奇怪的结果。您是否安装了类似于通用/纯文本的驱动程序?如果你这样做了,也许可以试着把它去掉。另外,如果没有其他办法,为您的特定打印机重新安装opos驱动程序总是一个好主意。因此,您确认我的问题是配置问题!而不是在我的代码中!!!我有另一台电脑,我会再次尝试安装和配置,我会告诉你结果。请您澄清一下,您所安装的“通用/纯文本”驱动程序是什么意思?您可以在windows中安装“通用/纯文本”类型的打印机,这是收据打印机的常见操作。你的代码看起来不错,加上它在POS for.Net应用程序中失败了。我正在努力解决它,但没有结果:/i我甚至在另一台计算机上安装了一个新的Win Seven,仍然存在同样的问题:在索赔之前一切都很顺利();这给了我一个错误!!!!有什么帮助吗?