【发布时间】:2011-10-15 01:29:36
【问题描述】:
我有一个 Epson TM-U220A,我正在编写和 c# 桌面应用程序来打印收据。但是找不到打印机。
如果我通过记事本发送某些东西,打印机会打印出奇怪的字符(因此可以正常工作)
我有以下几点:
- .Net v1.12.exe 的 POS
- OPOSN1.11.16(Espon Wrapper for .net)
- 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
}
错误:端口名称非法,或无法连接到设备。 在线:m_Printer.Claim(1000);
【问题讨论】:
-
你知道异常是在哪一行抛出的吗?
-
错误:端口名称不合法,或无法连接到设备。在线:m_Printer.Claim(1000);
-
你在使用opos或windows驱动是哪个drfiver?
标签: c# printing epson pos-for-.net