Naimish Dave

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




Re: .NET Compact Framework Symbol Barcode functionality

timg_msft

when you set a breakpoint on that line, what do you see

is objReader null

is objReader.Actions null

is this.symReaderData null

what does the call stack look like






Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Hi

Very sorry for toooo late reply.

Yes all three are null and call stack tell

BarcodeScanning.exe
NullReferenceException

at BarcodeScanning.BarcodeControl.BarcodeControl_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Application.Run()
at BarcodeScanning.Program.Main()

Please do reply me.

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

timg_msft

if objReader is null, have you set a breakpoint on the line where you expect it to be created/set Have you stepped over that breakpoint What happens






Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Yes, I have tried to put breakpont, I checked that objReader and ReaderData is coming as null.

I tried with Symbol's readymade samples which are supposed to work but unfortunately fails on my device (Symbol MC70).

I checked Sample.C example for bar code scanning and it works on my device but when it comes to SMDK 1.5 for .NET, everything starts throwing error. Symbol samples are not working!

Is there any setup or workaround for scanning bar code on Symbol device using SMDK 1.5 for .NET

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

timg_msft

This does not sound at all like a .NETCF issue. You will need to contact Symbol directly.




Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Yes, I am going to do that now.

BTW, do you have any code for this

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

timg_msft

sorry, I do not.






Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Its Ok, I appreciate for your help, Thanks

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

Federico Silberberg

Naimish,

The SDKs comes with Controls that you can add to the toolbar. Drop the Barcode control to a form or UserControl and give it a try. It should do all the proper work





Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Thanks for your reply

I have tried that but none of the SMDK samples are working on actual device!

Only one example given by Symbol is working, i.e. Samples.C.

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

gotcf.net

Naimish,

Please try the following code snippet (it does work for our customers for sure):

BarcodeReader reader = new BarcodeReader();
reader.ListChanged += new ListChangedEventHandler(reader_ListChanged);
reader.Start();

private void reader_ListChanged(object sender, ListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemAdded) {
ProcessReaderData(reader.ReaderData.Text);
reader.Clear();
}
}







Re: .NET Compact Framework Symbol Barcode functionality

Naimish Dave

Hi gotcf

Which SDK are you using for symbol barcode access. I am using SMDK .NET 1.5 and in this kit I was not able to find any class/object like BarcodeReader and even not even like ListChanged. Is this customized class, If yes then can you show me full code for barcode scanning

Regards,

Naimish Dave






Re: .NET Compact Framework Symbol Barcode functionality

gotcf.net

Naimish,

We use SMDK .NET v1.4 (deployed) and v1.5 (new development). Notice that the v 1.5 has official patch that can be found here. Please make sure you have actually installed the patch first as it looks like you have experienced the issues related to the runtime errors that were patched in Symbol.Barcode.dll library. The version of the Symbol.Barcode.dll library should read 1.5.1.2. Please follow the patch instructions carefully, as it requires you to have a few files to be replaced on both
development machines (manually) and on the device (automated).

The BarcodeReader can be found in Symbol.Barcode.dll, Symbol.Barcode namespace.