值不能为空POS.NET V1.12条码扫描器 [英] Value cannot be null POS.NET V1.12 Barcode Scanner
问题描述
嗨朋友
条形码扫描仪面临价值不能为空的问题。
并且此异常发生在this.scanner =(Scanner)explorer.CreateInstance(device);
指向设备。
如果能得到任何帮助来解决这个问题会很棒
Hi Friends
I am facing "value cannot be null" problem for a barcode scanner.
And the exception occurs at this.scanner =(Scanner)explorer.CreateInstance(device);
pointing to device.
It would be great if can get any help to resolve this
class bScan
{
public PosExplorer explorer;
public Scanner scanner;
string BarCodeReader;
public void Start_Scan()
{
// explorer = new PosExplorer();
// explorer.DeviceAddedEvent += new DeviceChangedEventHandler(explorer_DeviceAddedEvent);
// var device=explorer.GetDevice(DeviceType.Scanner);
;
}
public void read()
// public void explorer_DeviceAddedEvent(object sender,DeviceChangedEventArgs e)
{
explorer = new PosExplorer();
DeviceInfo device = explorer.GetDevice("Scanner",BarCodeReader);
this.scanner =(Scanner)explorer.CreateInstance(device);
this.scanner.Open();
this.scanner.Claim(1000);
this.scanner.DeviceEnabled = true;
this.scanner.DataEvent += new DataEventHandler(scanner_DataEvent);
this.scanner.DataEventEnabled = true;
this.scanner.DecodeData = true;
}
//}
public void scanner_DataEvent(object sender,DataEventArgs e)
{
string data;
ASCIIEncoding encoding=new ASCIIEncoding();
scanner.DataEventEnabled=true;
data=encoding.GetString(scanner.ScanDataLabel);
// listBox1.Items.Add(encoding.GetString(scanner.ScanDataLabel));
}
}
推荐答案
嗯,最可能的问题是此行返回null。
Well, the most likely problem is that this line returns null.
DeviceInfo device = explorer.GetDevice("Scanner",BarCodeReader);
然后你在下一行收到错误
Then you get an error on the next line
this.scanner = (Scanner)explorer.CreateInstance(device);
这是善良的如果将null作为参数发送,则会出现预期错误。
变量 BarCodeReader
是否有值?
据我所知,它没有初始化,所以如果发送一个空字符串或null会发生什么?
问题是我们不知道你的电脑是否安装了什么,所以很难提供更准确的帮助。
[更新]
以下是一些配置文档r POS v1.14。我认为它应该与您的版本类似,或者您可以下载并安装新版本。
手动管理.NET设备的POS [ ^ ]
阅读文档从来都不错。
And that is kind of an expected error if you send null as a parameter.
Should the variable BarCodeReader
have a value?
As far as I can see it is not initialized, so what happens if you send an empty string or null?
The problem is we don't know what you have installed or not on your computer, so it is difficult to give any more exact help.
[UPDATE]
Here is some configuration documentation for POS v1.14. It should be similar to your version, I think, or you can download and install the new version.
Manually managing POS for .NET devices[^]
It is never bad to read the documentation.
这篇关于值不能为空POS.NET V1.12条码扫描器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!