【问题标题】:PosExplorer().getDevices returning null in .Net applicationsPosExplorer().getDevices 在 .Net 应用程序中返回 null
【发布时间】:2015-04-16 21:28:08
【问题描述】:

我正在使用 .Net 开发计费应用程序。我需要使用 EPSON TM-T81 打印收据。我已经安装了所有必需的驱动程序和 MS POS v1.12。我可以通过 CheckHealth Utility 成功打印示例内容。所以看起来 PosPrinter 配置没有问题。但仍然 PosExplorer().getDevices 返回空值。我在 Windows 和 ASP.Net 应用程序中都尝试过,但仍然是同样的问题。 代码: PosPrinter m_Printer = null;

        //<<<step1>>>--Start
        //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
            {
                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

【问题讨论】:

    标签: c# asp.net printing pos-for-.net


    【解决方案1】:

    如果这正是您要运行的代码,那么问题在于 strLogicalName 不包含有效的 SO 或逻辑设备名称。 “PosPrinter”只是代码示例中的一个占位符(当然,除非您明确设置这样的逻辑名称)。

    为了找出系统中可用的 SO 名称/逻辑设备名称,请使用以下命令:

    "C:\Program Files (x86)\Microsoft Point Of Service\posdm.exe" listdevices /type:PosPrinter
    
    "C:\Program Files (x86)\Microsoft Point Of Service\posdm.exe" listnames /type:PosPrinter
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-03
      • 1970-01-01
      • 2019-02-07
      • 1970-01-01
      相关资源
      最近更新 更多