locked
POS for .NET and Symbol LS2208 RRS feed

  • Question

  • Hi! I use scanner Motorola (Symbol LS2208). I have downloaded OPOS the driver from official site Motorola. But when I try to use it in POS for .NET, I receive an error:

    Method Open threw an exception.  The device cannot perform the requested procedure.

    In what a problem? It is necessary to create the own Service object?

    Tuesday, May 11, 2010 6:36 AM

Answers

  • Hi,

    No, it should not be necessary to create your own service object... although some service objects from different manufacterers differ in quality to a great degree which is a shame.

    Unfortunately I do not know why you would get that error. Check you have the latest service object and maybe contact Symbol for help.

     

    Tuesday, May 11, 2010 8:50 PM
    Answerer

All replies

  • Hi,

    No, it should not be necessary to create your own service object... although some service objects from different manufacterers differ in quality to a great degree which is a shame.

    Unfortunately I do not know why you would get that error. Check you have the latest service object and maybe contact Symbol for help.

     

    Tuesday, May 11, 2010 8:50 PM
    Answerer
  • Did you ever resolve this issue? I am having the same problem..
    Wednesday, November 17, 2010 4:47 PM
  • Hi there,

    I just went through this and managed to solve it. In case you still have an issue, this is what you need to do:

    1. If you have downloaded the latest OPOS driver from Motorola/Symbol support website, you need to uninstall it.

    2. Call Motorola support at 1.800.653.5350 and ask them to send you an OPOS driver that is known to work with the Microsoft.NET framework. At this moment, I was given something called Motorola OPOS Management Suite version 1.5.04. Try this link which works now, but may not be available in the future:

    https://rcpt.yousendit.com/1003229459/6841265d62ddfec9b1ab04d9916153e9

    3. Once you have installed this OPOS driver, the Service Object Name to discover with your PosExplorer will be "SYMBOL_SCANNER".

    4. MAke sure your Scanner is not configured as a Keyboard emulator. To test that, open Notepad and scan any barcode. If the barcode number shows in the Notepad, your scanner is configured as a keyboard emulator and it won't work. You need to reconfigure it. From ther Quick Start Guide, you need to scan the Set Defaults barcode followed by the IBM Hand-Held USB barcode.

    5. After that your application should work. If it doesn't, there are other issues that need to addressed in a different way.

    Good luck,

    E

     

    Tuesday, December 7, 2010 8:05 PM
  •  To anyone looking at this for a solution to errors at .open() using pos for .net with the Symbol LS2208 (or others maybe) for the error Microsoft.PointOfService.PosControlException: Method Open threw an exception.  Could not read the device name key's default value, or could not convert the Programmatic ID it holds into a valid Class ID"

    it doesn't work, neither does changing permissions, making it full trust, installation orders, installation of ccos, etc etc. Motorola claim the OPOS driver you install with the sdk custom settings works. Trust me don't call or email their support, they even accused me of not even owning the scanner and not helping until I entered my serial number (even though the form didn't require it), and took forever to get to someone at symbol division who actually had a relevant discussion. Anyway, I think the issue seems to be that Opos  .Open() method takes the "DeviceName" as a parameter where the Pos for .net open() method expects the service object to set this. Since pos for .net has legacy support, Motorola isn't updating to specifically support it, although I think they tried because in the latest installation they added "DeviceNameOveride" to the registry key for SYMBOL_SCANNER, which doesn't work because STIOPOS.DLL needs to be fixed. The registry values do actually convert properly between CLSID and ProgID, and are fine, changing them doesn't make a difference, and using the exact same code but for a printer with known Pos for .net support works fine.  Setting a DeviceName in registry is ignored too, I think what's happening is it's searching for the device name parameter first, which is nothing, and attempting to open it from the registry, probably from a string they build appending the device name to OLEforRetail\ServiceOPOS\Scanner, and it's failing, and it takes a while before that thread is available, (also noticed the ThreadingModel isn't set for InProcServer32 ?). If this is the case, they should make it search for SYMBOL_SCANNER first and attempt to open it and then set the device name to it.

    I have found a solution for now, though it's really bad practice, and I hate it. Spam the scanner activation in a try/catch loop. It's bad, but it works, sometimes after a few errors, sometimes after 50+, but once the scanner is opened it works perfectly from then on, and on Win7 64bit (targeting x86) or 32bit forms or wpf  and targetting .net 4.0.

    This is a super simple version of how you do it.

    1) Create a new forms or wpf app targeting .net 4.0

    2) Change the build target from ANY CPU to x86.

    3) Add a reference to Microsoft.PointOfService.dll in Microsoft Point Of Service\SDK\

    4) Add a new application configuration file to project and name it App.config

    5) Change the contents of App.Config to the following

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <runtime>
        <NetFx40_LegacySecurityPolicy enabled="true"/>
      </runtime>
    </configuration>

    6) This is some exremely basic code for how to do it. Since a logical name is not set by Motorola, we will use the GetDevices method instead of get device.

    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.PointOfService;

    namespace Symbol_Scanner
    {
        public partial class Form1 : Form
        {
            private PosExplorer _explorer;
            private Scanner _curScanner;
            private DeviceInfo _devScanner;

            public Form1()
            {
                InitializeComponent();
                InitExplorer();
            }

            private void InitExplorer()
            {
                _explorer = new PosExplorer();

                foreach (var scanner in _explorer.GetDevices(DeviceType.Scanner).Cast<DeviceInfo>().Where(scanner => scanner.ServiceObjectName == "SYMBOL_SCANNER"))
                {
                    _devScanner = scanner;
                    ActivateScanner();
                }
            }

            private void ActivateScanner()
            {
                try
                {
                    if (_devScanner == null || _devScanner.IsDeviceInfoOf(_curScanner))
                        return;

                    DeactivateScanner();
                    _curScanner = (Scanner)_explorer.CreateInstance(_devScanner);

                    _curScanner.Open();
                    _curScanner.Claim(1000);
                    _curScanner.DeviceEnabled = true;
                    _curScanner.DataEvent += ActiveScannerDataEvent;
                    _curScanner.ErrorEvent += ActiveScannerErrorEvent;
                    _curScanner.DecodeData = true;
                    _curScanner.DataEventEnabled = true;
                    MessageBox.Show("Scanner Activated");
                }
                catch (PosControlException ex)
                {
                    // log ex here it will be error code 303
                    _curScanner = null;
                    ActivateScanner(); // this is the spam
                }
            }

            private void DeactivateScanner()
            {
                if (_curScanner == null)
                    return;
                _curScanner.Close();
                _curScanner = null;
            }


            private void ActiveScannerDataEvent(object sender, DataEventArgs e)
            {
                try
                {
                    var encoder = new ASCIIEncoding();
                    var scandata = encoder.GetString(_curScanner.ScanDataLabel);
                    MessageBox.Show(scandata);
                    _curScanner.DataEventEnabled = true;
                }
                catch (PosControlException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            private void ActiveScannerErrorEvent(object sender, DeviceErrorEventArgs e)
            {
                try
                {
                    _curScanner.DataEventEnabled = true;
                }
                catch (PosControlException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
    }

    This should activate after a second and then when you scan a barcode it will show up in a mesage box. To add a logical name to the registry open up regedit and go to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OLEforRetail\ServiceOPOS\Scanner (64bit) or HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\Scanner (32bit) and add a new string value with the name of your device as the name, and the value also as the name. So for instance,

    "SYMBOL_SCANNER" as name and "SYMBOL_SCANNER" as value. Then you can use _explorer.GetDevice(Scanner, "SYMBOL_SCANNER") instead of GetDevices.

    I hope this helps someone, it is a truly frustrating issue. If anyone wants a more complete example project feel free to ask.

    • Proposed as answer by James K- Thursday, April 19, 2012 5:26 AM
    Thursday, April 19, 2012 5:23 AM
  • Hi James

    Is it posible you to send me sample in vb.net,cos i tried to convert the code but having to many

    error.

    Thanks

    Thursday, April 19, 2012 2:35 PM
  • syed_ju: I don't write in VB but I will try today. Can you post the errors you recieve?
    Thursday, April 19, 2012 4:55 PM
  • There are various VB.NET and C# solutions that come with my POS for .NET book: http://www.seanliming.com/POSforNET.html  / http://www.annabooks.com/Book_PGPOS.html

    -Sean


    www.sjjmicro.com / www.seanliming.com / www.annabooks.com, Book Author - Pro Guide to WES 7, XP Embedded Advanced, Pro Guide to POS for .NET

    Thursday, April 19, 2012 5:17 PM
    Answerer
  • syed_ju  here is the same code but for VB. I just "learned" vb for this by googling, but it seems to work. Don't forget to add an App.Config with the security policy if you're targeting .net 4.0, you could also add it to the runtime section of devenv.exe.config. This should loop through and activate on load, and then when you scan a messagebox will show with the scanned data showing. Hope it works for you.

    Imports Microsoft.PointOfService
    Imports System.Linq
    Imports System.Text

    Public Class Form1

        Private WithEvents _explorer As PosExplorer
        Private WithEvents _scanner As Scanner
        Private _devScanner As DeviceInfo

        Public Sub Form1Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles Me.Load
            InitExplorer()
        End Sub

        Private Sub InitExplorer()
            _explorer = New PosExplorer(Me)

            For Each device As DeviceInfo In From device1 As DeviceInfo In _explorer.GetDevices(DeviceType.Scanner) Where (device1.ServiceObjectName = "SYMBOL_SCANNER")
                _devScanner = device
                ActivateScanner()
            Next
        End Sub

        Private Sub ActivateScanner()
            Try
                If (_devScanner.IsDeviceInfoOf(_scanner) = True) Then
                    Return
                End If

                If (_devScanner Is Nothing) Then
                    Return
                End If

                DeactivateScanner()
                _scanner = _explorer.CreateInstance(_devScanner)
                _scanner.Open()
                _scanner.Claim(1000)
                _scanner.DeviceEnabled = True
                _scanner.DecodeData = True
                _scanner.DataEventEnabled = True
                MessageBox.Show("Scanner Activated")
            Catch ex As PosControlException
                _scanner = Nothing
                ActivateScanner()
            End Try
        End Sub

        Private Sub DeactivateScanner()

            If (_scanner Is Nothing) Then
                Return
            End If
            _scanner.Close()
            _scanner = Nothing
        End Sub

        Private Sub ActiveScannerDataEvent(ByVal sender As Object, ByVal e As Microsoft.PointOfService.DataEventArgs) Handles _scanner.DataEvent
            Try
                Dim encoder As New ASCIIEncoding()
                Dim scandata = encoder.GetString(_scanner.ScanDataLabel)
                MessageBox.Show(scandata)
                _scanner.DataEventEnabled = True

            Catch ex As PosControlException
                MessageBox.Show(ex.ToString())
            End Try
        End Sub

        Private Sub ActiveScannerErrorEvent(ByVal sender As Object, ByVal e As Microsoft.PointOfService.DeviceErrorEventArgs) Handles _scanner.ErrorEvent
            Try
                _scanner.DataEventEnabled = True
            Catch ex As PosControlException
                MessageBox.Show(ex.ToString)
            End Try
        End Sub

    End Class



    • Edited by James K- Thursday, April 19, 2012 7:08 PM
    Thursday, April 19, 2012 7:05 PM
  • Can you confirm that the fix works for you ?
    Saturday, April 21, 2012 5:12 PM
  • Im very very sorry for late  reply.

    Cos i was busy in another application.

    Just now i checked this code but im getting this error Method Open threw an exception.  The service object returned a failure status from its open call, but does not have a more specific failure code.

    If im using STI_SCANNER instead of SYMBOL_SCANNER,its only open the scanner but no event is firing........

    Wednesday, April 25, 2012 9:14 PM
  • If SYMBOL_SCANNER isn't showing up and you want to use it, make sure you install the OPOS driver for the scanner from motorola's site. I think they have a seperate driver now but you can get the latest sdk and when the option comes up for a custom installation, choose custom, and make sure OPOS is clicked, then install. After, open up regedit and browse to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OLEforRetail\ServiceOPOS\Scanner if it's 64bit, or HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\Scanner for 32bit. You can use any of those names and it should work. Mine activates with MOTOROLA_SCANNER, STI_USBSCANNER, or SYMBOL_SCANNER, they're all the same so I don't know why they bother with all three. Make sure the code you're using is exactly what I posted, the point of it is to spam the activation to get past PosControlException 303.

    Thursday, April 26, 2012 7:29 PM
  • I guess I should say, make sure ActivateScanner() is not within any exception handling.
    Monday, April 30, 2012 10:03 PM
  • I had success at past making it work. But currently symbol has realeased 64 bit drivers at July .Without hacking i cant install OPOS 32bit at my 64 machine. 

    http://support.symbol.com/support/search.do?cmd=displayKC&docType=kc&externalId=13517&sliceId=&dialogID=293888755&stateId=1

    The problem is that these latest drivers wont work with POS for .NET . With simple OPOS they work. PosExplorer even if it is compiled 64bit  sees only Wow3264Node at registery. Manualy copying Scanner from registry to Wow3264Node i saw them.If i download 32bit drivers it wont let me install them.

    Also CCO are 32bit and they use assembly and seems imposible/hard/not worth to compile at 64bit...

    Do you have any suggestion other than using symbol's dll coredriver.dll ?


    • Edited by Parhs Thursday, November 15, 2012 3:36 PM
    Thursday, November 15, 2012 3:35 PM