Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 爱普生销售点打印机-无法使用c打印#_C#_Printing_Epson_Pos For .net - Fatal编程技术网

C# 爱普生销售点打印机-无法使用c打印#

C# 爱普生销售点打印机-无法使用c打印#,c#,printing,epson,pos-for-.net,C#,Printing,Epson,Pos For .net,我有一个爱普生TM-U220A,我正在编写和c#桌面应用程序来打印收据。但它找不到打印机 如果我通过记事本发送东西,打印机会打印奇怪的字符(因此它可以工作) 我有以下资料: .Net v1.12.exe的POS OPOSN1.11.16(Espon.net包装器) 安装了Espon驱动程序 打印机的USB接口 代码: private void FormLoad(对象发送方,System.EventArgs e) { //--开始 //使用已在SetupPOS上设置的逻辑设备名称。 字符串st

我有一个爱普生TM-U220A,我正在编写和c#桌面应用程序来打印收据。但它找不到打印机

如果我通过记事本发送东西,打印机会打印奇怪的字符(因此它可以工作)

我有以下资料:

  • .Net v1.12.exe的POS
  • OPOSN1.11.16(Espon.net包装器)
  • 安装了Espon驱动程序
  • 打印机的USB接口
代码:

private void FormLoad(对象发送方,System.EventArgs e)
{
//--开始
//使用已在SetupPOS上设置的逻辑设备名称。
字符串strLogicalName=“PosPrinter”;
//字符串strLogicalName=“ESDPRT001”;
尝试
{
//创建PosExplorer
PosExplorer PosExplorer=新的PosExplorer();
DeviceInfo DeviceInfo=null;
尝试
{
deviceInfo=posExplorer.GetDevice(DeviceType.PosPrinter,strLogicalName);
m_Printer=(PosPrinter)posExplorer.CreateInstance(deviceInfo);
}
捕获(例外)
{
ChangeButtonStatus();
返回;
}
//打开设备
m_Printer.Open();
//获取已打开设备的独占控制权。
//然后从其他应用程序禁用该设备。
m_打印机索赔(1000);
//启用设备。
m_Printer.DeviceEnabled=真;
}
捕获(PosControlException)
{
ChangeButtonStatus();
}
//--结束
}

错误:端口名非法,或无法连接到设备。 在线:m_打印机。索赔(1000)


根据我使用爱普生POS打印机的经验,安装了Windows打印机驱动程序后,可以防止以任何其他方式使用打印机

我认为您应该尝试的第一件事是删除打印机,在SetupPOS中重新设置,然后重试您的程序


祝你好运

您打开打印机的打印机端口了吗?这可能就是问题所在

我们需要为打印机打开并启用以下端口:

9100到9100,协议设置为“两者”
81到1800,协议设置为“两者”

请检查configuration.xml文件。端口名必须与xml和SetupPOS中的端口名相同,且应位于串行端口中

有关xml配置,请检查此链接

您知道引发异常的行吗?错误:端口名非法,或无法连接到设备。在线:m_打印机。索赔(1000);您使用的是opos还是windows驱动程序?它的工作原理是。。。不知道为什么会有这样的问题。
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

        }