- Joined
- Jun 22, 2007
- Messages
- 3
- Reaction score
- 0
Hi,
I am trying to implement barcode functionality on my device (Sumbol MC70), I am using,
- VS 2005
- Compact FW 2.0
- Symbol SDK 1.5 for .NET
- Windows Mobile 5.0 Pocket PC SDK
I have referred Symbol developers guide and created a device application but its throwing NullReference error on Sysmbol.Barcode.ReaderDAta object creation line !!! I have marked that line with Red color in below code.
following is my code, Please someone have a look and let me know what I am missing:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace BarcodeScanning
{
public partial class frmBarcodeScanning : Form
{
private Symbol.Barcode.Reader objReader = null;
private Symbol.Barcode.ReaderData symReaderData = null;
public frmBarcodeScanning()
{
InitializeComponent();
}
private void menuItem1_Click(object sender, EventArgs e)
{
this.Close();
}
private void barcode1_OnStatus11(object sender, EventArgs e)
{
Symbol.Barcode.BarcodeStatus barcodeStatus = objReader.GetNextStatus();
label2.Text += barcodeStatus.Text;
}
private void barcode1_OnRead11( object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show(symReaderData.Text, "HelloScan");
this.ReadData();
return;
//try
//{
// switch (symReaderData.Result)
// {
// case Symbol.Results.SUCCESS:
// listBox1.Items.Add("Barcode Device: " + symReaderData.Source.ToString());
// listBox1.Items.Add("Data Read: " + symReaderData.Text.ToString());
// listBox1.Items.Add("------------------");
// this.ReadData();
// break;
// default:
// listBox1.Items.Add("No data was read.");
// listBox1.Items.Add("Status of Read: " + symReaderData.Result.ToString());
// listBox1.Items.Add("------------------");
// break;
// }
//}
//catch (Exception ex)
//{
// listBox1.Items.Add(ex.Message.ToString());
// listBox1.Items.Add("------------------");
//}
}
private bool InitReader()
{
try
{
// Get selected device from user
////Symbol.Generic.Device MyDevice =
//// Symbol.StandardForms.SelectDevice.Select(
//// Symbol.Barcode.Device.Title,
//// Symbol.Barcode.Device.AvailableDevices);
////if (MyDevice == null)
////{
//// MessageBox.Show("No Device Selected", "SelectDevice");
//// return false;
////}
// Create the reader, based on selected device
this.objReader = new Symbol.Barcode.Reader();
////this.objReader = new Symbol.Barcode.Reader(MyDevice);
this.symReaderData =
new Symbol.Barcode.ReaderData
(Symbol.Barcode.ReaderDataTypes.Text, Symbol.Barcode.ReaderDataLengths.DefaultText);
//"at Symbol.Barcode.ReaderParams.SetReaderParams()\r\nat Symbol.Barcode.Actions.Read()\r\nat BarcodeScanning.frmBarcodeScanning.ReadData()\r\nat BarcodeScanning.frmBarcodeScanning.frmBarcodeScanning_Load()\r\nat System.Windows.Forms.Form.OnLoad()\r\nat System.Windows.Forms.Form._SetVisibleNotify()\r\nat System.Windows.Forms.Control.set_Visible()\r\nat System.Windows.Forms.Application.Run()\r\nat BarcodeScanning.Program.Main()\r\n"
////objReader.ReaderParameters.ReaderType = Symbol.Barcode.READER_TYPE.READER_TYPE_LASER;
////objReader.ReaderParameters.ReaderSpecific.ImagerSpecific.AimType = Symbol.Barcode.AIM_TYPE.AIM_TYPE_TRIGGER;
////objReader.Parameters.CodeIdType = Symbol.Barcode.CodeIdTypes.AIM;
//this.symReaderData = (Symbol.Barcode.ReaderData)barcode1.Reader.Actions.NewReaderData();
objReader.ReadNotify += new EventHandler(barcode1_OnRead11);
objReader.StatusNotify += new EventHandler(barcode1_OnStatus11);
//barcode1.ReaderData = this.symReaderData;
objReader.Actions.Enable();
//barcode1.EnableScanner = true;
return true;
}
catch (Exception ex)
{
return false;
}
}
//"at Symbol.Barcode.ReaderParams.SetReaderParams()\r\nat Symbol.Barcode.Actions.Read()\r\nat BarcodeScanning.frmBarcodeScanning.ReadData()\r\nat BarcodeScanning.frmBarcodeScanning.frmBarcodeScanning_Load()\r\nat System.Windows.Forms.Form.OnLoad()\r\nat System.Windows.Forms.Form._SetVisibleNotify()\r\nat System.Windows.Forms.Control.set_Visible()\r\nat System.Windows.Forms.Application.Run()\r\nat BarcodeScanning.Program.Main()\r\n"
private void ReadData()
{
objReader.Actions.Read(this.symReaderData);
//barcode1.Reader.Actions.Read(this.symReaderData);
}
private void cmdRead2_Click(object sender, EventArgs e)
{
//"at Symbol.Barcode.BarcodeMarshal.GetSoftTrigger()\r\nat Symbol.Barcode.Actions.GetSoftTrigger()\r\nat Symbol.Barcode.Info.get_SoftTrigger()\r\nat Symbol.Barcode.Info.set_SoftTrigger()\r\nat Symbol.Barcode.Actions.ToggleSoftTrigger()\r\nat BarcodeScanning.frmBarcodeScanning.cmdRead2_Click()\r\nat System.Windows.Forms.Control.OnClick()\r\nat System.Windows.Forms.Button.OnClick()\r\nat System.Windows.Forms.ButtonBase.WnProc()\r\nat System.Windows.Forms.Control._InternalWnProc()\r\nat Microsoft.AGL.Forms.EVL.EnterMainLoop()\r\nat System.Windows.Forms.Application.Run()\r\nat BarcodeScanning.Program.Main()\r\n"
objReader.Actions.ToggleSoftTrigger();
//barcode1.Reader.Actions.ToggleSoftTrigger();
}
private void cmdRead3_Click(object sender, EventArgs e)
{
//barcode1.Reader.Actions.Flush();
objReader.Actions.Flush();
}
private void frmBarcodeScanning_Load(object sender, EventArgs e)
{
if (this.InitReader())
{
this.ReadData();
}
}
private void label2_ParentChanged(object sender, EventArgs e)
{
}
private void frmBarcodeScanning_Closing(object sender, CancelEventArgs e)
{
objReader.Actions.Flush();
objReader.Actions.Disable();
objReader.Dispose();
symReaderData.Dispose();
return;
}
}
}
Regards,
Tomy Hanks