为什么设置DataEventEnabled = true会导致异常?

编程入门 行业动态 更新时间:2024-10-25 14:22:34
本文介绍了为什么设置DataEventEnabled = true会导致异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

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

解决方案

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

social.msdn.microsoft/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:

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

更多推荐

为什么设置DataEventEnabled = true会导致异常?

本文发布于:2023-11-24 21:20:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   DataEventEnabled   true

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!