2016-01-22 85 views
0

我正在使用C#開發摩托羅拉設備「MC67」,我在初始化掃描儀時遇到了問題。Motorolla設備掃描問題

我使用的代碼似乎是通用的,因爲我在互聯網上發現了類似的例子;參考這裏是導致我的問題代碼:

/// <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「

現在奇怪的是我能夠正確地在設備上使用掃描儀,所以我可以掃描條形碼並讀取數據前ception,但它發生的事實關係到我,所以我試圖阻止它。

有沒有人有任何想法,爲什麼我得到異常或任何建議我可以嘗試?

回答

0

這是符號庫中的「已處理」異常。只需關閉拋出異常的斷點--Ctrl-Alt-E,在「公共語言運行時異常」行中取消勾選「投擲」下的框。不幸的是,如果你試圖調試一個不能正常工作的異常,那麼每當這個異常出現時你都必須繼續按下播放。

我還沒有找到一種方法來讓它停止拋出異常,雖然...我真的很想關閉任何功能失敗的功能。

+0

這似乎與我所看到的是一樣的;是的,我可以取消勾選勾選框並且不再拋出異常,但我不喜歡它確實發生如此理想的事實,我想阻止它發生。 – plingingo