none
Help with microsoft Opos printing RRS feed

  • Question

  • Hi, have an epson TM-T20II pos printer.

    i'm having problems in this part to test the printer with code, printer is instaled on usb port

        Public Shared Function GetAndInitPosPrinter() As Microsoft.PointOfService.PosPrinter
            Dim pe As New PosExplorer()
            Dim ppdi = pe.GetDevice(DeviceType.PosPrinter, "MyPosPrinter1")
            Dim pp As Microsoft.PointOfService.PosPrinter = pe.CreateInstance(ppdi) 'error says i need to determine a null object
            pp.Open()
            pp.Claim(250)
            pp.DeviceEnabled = True
            Return pp
        End Function

    Thursday, June 8, 2017 1:36 AM

All replies

  • i'm having problems in this part to test the printer with code, printer is instaled on usb port

    You need to check that GetDevice has succeeded before trying to use the device it returns.

    Questions about POS should be asked in the POS forum:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=posfordotnet

    Thursday, June 8, 2017 4:32 AM
  • Hi Oxelotl,

    According to your code, I think that the  pe.GetDevice(DeviceType.PosPrinter, "MyPosPrinter1")=null, so you get this error.

    From PosExplorer.GetDevice Method (String, String), we can see that  logical names must be configured for the device by using either PosDm.exe or WMI Before using GetDevice. You cannot pass the service object name for logicalName

    Dim type As String
    Dim logicalName As String
    Dim returnValue As DeviceInfo
    Dim posExplorer1 As PosExplorer
    returnValue = posExplorer1.GetDevice(type, logicalName)

    If you have 2 or more devices of the same type and you issue GetDevice() function without logical name (only device type) then you will get exception if there is not defined Default device. I think the best practice is to call GetDevices method, show the available devices in a combobox - then the user will choose which one to use. Then call GetDevice with the selected name.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 8, 2017 7:07 AM
    Moderator
  • thanks a lot for your help i changed the logical name on the Epson Opos setup to T20 for easy and quick reference now it looks like this, but still not working.

    been seraching on the Epson Opos examples too, still can get to print even the simplest sample

    will paste the complete code of it at the end.

     '<<<step1>>>--Start
            'Use a Logical Device Name which has been set on the SetupPOS.
            Dim strLogicalName As String
            Dim deviceInfo As DeviceInfo
            Dim posExplorer As PosExplorer
    
            strLogicalName = "T20"
    
            'Create PosExplorer
            posExplorer = New PosExplorer
    
            m_Printer = Nothing
    
            Try
    
                deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName)
                m_Printer = posExplorer.CreateInstance(deviceInfo)
    
            Catch ex As Exception
                ChangeButtonStatus()
                Return
            End Try
    
            Try
    
                '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 ex As PosControlException
    
                ChangeButtonStatus()
    
            End Try



    • Edited by Oxelotl Thursday, June 8, 2017 6:09 PM
    Thursday, June 8, 2017 6:08 PM
  • Hi Oxelotl,

    Do you didn't still get deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName) value? Is there other error message?

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 28, 2017 7:17 AM
    Moderator
  • There is a case that it is caused by not running the SetupPOS tool as an administrator.
    Execute the SetupPOS tool as an administrator, then set the logical name and apply.

    Although it is an article in Japanese, it is below.
    Windows7で POS for .NET を利用した、EPSON TM-T70 Open に失敗しますhttps://social.msdn.microsoft.com/Forums/ja-JP/f07592dc-354e-4069-bbaf-c99fd55b8e27/windows7-pos-for-net-epson-tmt70-open-?forum=netfxgeneralja

    Another possibility is that the running service object is not the POS for.NET native, but the OPOS service object.
    In that case, please use the GetDevices() method instead of the GetDevice() method.
    Usage is as follows.

    1.Acquire the device collection by calling the GetDevices method with PosPrinter as the type parameter and Opos or OposAndCompatibilityLevel1 as the compatibility parameter.

    2.Search the device information with the device name key or logical device name of the device being used defined in the OPOS registry from the acquired device collection, and perform CreateInstance based on it.

    3.Call Open method using created object.

    Friday, January 5, 2018 4:22 AM