【问题标题】:Motorolla Device Scanning Issue摩托罗拉设备扫描问题
【发布时间】:2016-04-28 21:34:12
【问题描述】:

我正在为摩托罗拉设备“MC67”使用 C# 进行开发,但在初始化扫描仪时遇到了问题。

我使用的代码似乎是通用的,因为我在 Internet 上找到了类似的示例;供参考的是导致我出现问题的代码:

    /// <summary>
    /// Initialize the reader.
    /// </summary>
    /// 
    public override bool InitReader()
    {
        Logger.Instance.Debug("InitReader");

        bool result = false;

        //      Logger.Instance.AddToDebuggerLog("Symbol.InitReader");

        // If reader is already present then fail initialize
        if (this._MyReader != null)
        {
            return false;
        }
        try
        {
            // Create new reader, first available reader will be used.
            this._MyReader = new Symbol.Barcode.Reader();

            // Create reader data
            this._MyReaderData = new Symbol.Barcode.ReaderData(
              Symbol.Barcode.ReaderDataTypes.Text,
              Symbol.Barcode.ReaderDataLengths.MaximumLabel);

            // Enable reader, with wait cursor
            this._MyReader.Actions.Enable();

            if ((GetDeviceType() != DeviceTypes.SymbolMC3070) && (GetDeviceType() != DeviceTypes.SymbolMC3090BT))
            {
                this._MyReader.Parameters.Feedback.Success.BeepTime = 0;
            }
            else
            {
                this._MyReader.Parameters.Feedback.Success.BeepTime = 50;
            }

            SetScannerDecoderTypeToUseWithScanSys();

            result = true;
        }
        catch (Exception ex)
        {
            // Something has gone wrong Initializing barcode reader etc

            // Log Exception
            Logger.Instance.Exception("InitReader", ex);

            // Ensure reader is Disposed
            if (_MyReader != null)
            {
                try
                {
                    _MyReader.Dispose();
                }
                catch
                {
                    // Just incase something goes wrong
                    Logger.Instance.Error("Error Disposing MyReader in InitReader Exception");
                }
                _MyReader = null;
            }

            // Ensure ReaderData is Disposed
            if (_MyReaderData != null)
            {
                try
                {
                    _MyReaderData.Dispose();
                }
                catch
                {
                    // Just incase something goes wrong
                    Logger.Instance.Error("Error Disposing MyReaderData in InitReader Exception");
                }
                _MyReaderData = null;
            }

            // null the EventHandler
            _MyEventHandler = null;
        }
        return result;
    }

我的问题是,当调用上述方法时,下面一行产生异常错误:

this._MyReader.Actions.Enable();

例外是“OperationFailureException”,错误消息提到“获取所有支持的属性失败:E_SCN_INVALIDIOCTRL”

现在奇怪的是,我实际上能够正确使用设备上的扫描仪,因此即使出现此异常,我也可以扫描条形码并读取数据,但它正在发生的事实让我很担心,所以我试图阻止它。

有没有人知道我为什么会收到异常或任何我可以尝试的事情的建议?

【问题讨论】:

    标签: c# symbols motorola


    【解决方案1】:

    这是符号库中的“已处理”异常。只需关闭抛出异常的断点 - Ctrl-Alt-E,在“公共语言运行时异常”行中取消选中“抛出”下的框。不幸的是,如果您尝试调试无法正常工作的异常,则每次出现此异常时都必须按住播放键。

    我还没有找到一种方法让它停止抛出异常......我真的很想能够关闭任何失败的功能。

    【讨论】:

    • 这似乎和我看到的一样;是的,我可以取消选中复选框并且不再抛出异常,但我不喜欢它确实发生的事实,所以理想情况下我想阻止它发生。
    猜你喜欢
    • 1970-01-01
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多