为什么设置DataEventEnabled = true会导致异常? [英] Why does setting DataEventEnabled = true cause an exception?

查看:67
本文介绍了为什么设置DataEventEnabled = true会导致异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到一些奇怪的事情,我不太明白。当我使用带有旧扫描程序服务对象的POS for .Net时,当我获得条形码扫描事件以接收新事件时,您需要将DataEventEnabled属性设置为true。否则
你只得到第一个事件,而不是第二个事件。


奇怪的是,当我在调试器下运行时,我总是得到一个带有消息的PosControlException异常"无法设置属性DataEventEnabled。"。这在创建扫描程序对象时第一次打开时不会发生,但
总是在事件处理程序中。


当我直接连接到扫描程序到OCX服务时对象(不通过.Net的POS)我没有得到这个。


起初我以为我做错了,因为POS for .Net的示例应用程序工作得很好。直到我意识到它也有同样的问题!在示例代码中,他们有一个空的try / catch块来设置该值以忽略异常:


 
尝试
{
dataEventEnabled.SetValue(posCommon) , true null );
}
catch {}

解决方案

没人?我从一段时间后发现了这个帖子,我想知道这个人是否遇到了同样的问题:


http://social.msdn.microsoft.com/Forums/en-US / posfordotnet /线程/ 8a5ed3b5-7f41-4fd7-ba32-f53631cc7870


I have noticed something odd that I don't quite understand. When I am using POS for .Net with a legacy scanner service object, when I get a barcode scanned event in order to receive a new event, you need to set the DataEventEnabled property to true. Otherwise you only get the first event, and not the second event.

What is odd is that when I run under a debugger, I always get a PosControlException exception with the message "Failed to set property DataEventEnabled.". This never happens the first time you turn this on when you create the scanner object, but always in the event handler.

When I connect to the scanner directly to the OCX service object (not going through POS for .Net) I don't get this.

At first I thought I was doing something wrong, as the sample app in POS for .Net works just fine. Until I realized it ALSO has the same problem! And that in the sample code, they have an empty try/catch block around setting that value to ignore the exception:

try
{
  dataEventEnabled.SetValue(posCommon, true, null);
} 
catch { }

解决方案

Nobody? I found this thread from a while back, and I wonder if this guy was running into the same issue:

http://social.msdn.microsoft.com/Forums/en-US/posfordotnet/thread/8a5ed3b5-7f41-4fd7-ba32-f53631cc7870


这篇关于为什么设置DataEventEnabled = true会导致异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆