【发布时间】:2011-04-29 09:07:45
【问题描述】:
当前 C# POS.NET 打印问题:
PrintNormal() Throws Exception = '未初始化'CheckHealth = '未初始化'
打印到 Epson TM-T88IV 时出现“未初始化”异常
将 POS 用于 .NET 1.12 和 Epson OPOS ADK 用于 .NET (v1.11.9) 服务对象 为 PosPrinter 成功打开、声明和设置 DeviceEnabled-true
问题在此之后向打印机发送任何内容 PrintNormal() 导致抛出“未初始化”异常。 Epson OPOS ADK 附带的 CheckHealth Utility 会导致完全相同的错误。使用 PrintNormal(PrinterStation.Receipt 时,异常为 '未安装指定的工作站。"
打印机使用直接并行打印效果很好 打印机本身打印
我们怎么能不抛出带有消息的豁免 - '它未初始化'?
void K8POSPrint()
{
/// <summary>
/// PosPrinter object
/// </summary>
PosPrinter m_Printer = null;
try
{
//Use a Logical Device Name which has been set on the SetupPOS.
string strLogicalName = "PosPrinter";
try
{
//Create PosExplorer
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
try
{
// Device Info is not null when the printer has the logical name
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
}
catch (Exception ExDevice)
{
}
//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;
// ////CheckHealth.
//m_Printer.CheckHealth(Microsoft.PointOfService.HealthCheckLevel.Interactive);
// //As using the PrintNormal method, send strings to a printer, and print it [\n] is the standard code for starting a new line.
/// Current Issue Next Line thows an exception - 'It is not initialized'
m_Printer.PrintNormal(PrinterStation.Receipt, "Hey Now OPOS for .NET\n");
// the next line would throw the exception 'The specified station is not mounted.'
// m_Printer.PrintNormal(PrinterStation.Slip,"Hey Now Slip OPOS.NET\n");
}
catch (PosControlException)
{
}
}
catch (Exception ex)
{
}
}
附加信息:
尝试在 pos 打印机上打印时安装的程序有:
1.安装APD4打印机驱动Epson TI88IV
APD_412EWM.exe
https://www.epsonexpert.com/ee/techRes/index.htm?ProductId=570
在控制面板打印机中进行此设置后,我可以选择打印机的属性并成功向打印机打印测试。
2。已安装 Microsoft POS.NET 1.12
POSfor.NET.msi
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=eaae202a-0fcc-406a-8fde-35713d7841ca
3。安装爱普生OPOS ADK v2.67
ADK267ER4.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
4。为 .NET 1.11.8 安装了 EPSON OPOS ADK
OPOSN 1 11 18.exe
https://www.epsonexpert.com/ee/appDev/appDevOPOS.htm
5。安装的 OPOS 公共控制对象 1.13.001
OPOS_CCOs_1.13.001.msi
http://monroecs.com/oposccos_current.htm
6。 SetupPOS - 添加了设备和逻辑名称
7.检查健康仍然抛出错误
它没有初始化
OPOS_E_ILLEGAL 10007 (0x00002717)
【问题讨论】:
-
我认为你的 try catch 嵌套是问题所在,你在这里没有得到真正的问题。尝试删除一些 Try catch 代码,只留下一个。然后你就会看到真正的问题是什么。
-
您是否安装了名为 PosPrinter 的 OPOS 打印机?您可以在 HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\PosPrinter 下的注册表中检查应该有一个名为
PosPrinter的子键。如果尝试删除,是否在 Windows 中的打印机和设备中设置了打印机?据我回忆,如果打印机是在 Windows 中设置的,它不会总是在 OPOS 中工作。
标签: c# .net wpf point-of-sale pos-for-.net