我有一台Epson TM-U220A,我正在编写和c#桌面应用程序来打印收据.但它无法找到打印机.
如果我通过记事本发送东西(因此它的工作),打印机打印奇怪的字符
我有以下内容:
> POS for .Net v1.12.exe
> OPOSN1.11.16(针对.net的Espon Wrapper)
>安装了Espon驱动程序
>打印机的USB接口.
码:
private void FormLoad(object sender,System.EventArgs e) { //<<<step1>>>--Start //Use a Logical Device Name which has been set on the SetupPOS. string strLogicalName = "PosPrinter"; // string strLogicalName = "ESDPRT001"; try { //Create PosExplorer PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; try { deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter,strLogicalName); m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo); } catch (Exception) { ChangeButtonStatus(); return; } //Open the device m_Printer.Open(); //Get the exclusive control right for the opened device. //Then the device is disable from other application. m_Printer.Claim(1000); //Enable the device. m_Printer.DeviceEnabled = true; } catch (PosControlException) { ChangeButtonStatus(); } //<<<step1>>>--End }
解决方法
根据我使用Epson POS的经验,安装了Windows打印机驱动程序的打印机无法以任何其他方式使用打印机.
我认为你应该尝试的第一件事是删除打印机,在SetupPOS中再次设置它,然后再次尝试你的程序.
祝好运!