本文介绍了HACL终端仿真器自动化:ECLPS对象和线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用IBM HACL进行终端仿真器自动化。在执行线程中,我可以访问HACL编程对象及其属性/方法。我的意图不是阻止主线程,而是通过后台工作人员完成工作。在这里我所有的尝试都失败了。 我尝试过: 这有效:
I'm working on terminal emulator automation using IBM HACL. In the execution thread I can access the HACL programming objects and their properties/methods. My intention is not to block the main thread, but have the job done via background worker. Here all my attempts failed. What I have tried: This works:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Dim pConnList As AutConnListTypeLibrary.AutConnList pConnList = New AutConnListTypeLibrary.AutConnList pConnList.Refresh() Debug.Print("Number of sessions: " & pConnList.Count) 'Result: 'Number of sessions: 2 End Sub但后台工作人员无法做到这一点。在创建对象实例时会抛出异常:
But the same is not possible from the background worker. When creating the instance of the object the exception is thrown:
Private Sub bw_DoWork(sender As Object, e As DoWorkEventArgs) Handles bw.DoWork Dim pConnList As AutConnListTypeLibrary.AutConnList Try pConnList = New AutConnListTypeLibrary.AutConnList pConnList.Refresh() Debug.Print("Number of sessions: " & pConnList.Count) Catch ex As Exception Debug.Print(ex.Message.ToString) 'Result: 'Exception thrown: 'System.InvalidCastException' in Pcomm test.exe 'Unable to cast COM object of type 'System.__ComObject' to interface type 'AutConnListTypeLibrary.AutConnList'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3CB39CC1-6F18-11D0-910D-0004AC3617E1}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). End Try End Sub推荐答案
使用后期绑定 pConnList = CreateObject(PCOMM.AutConnList) 应该有帮助 如果您想使用intelisense您可以尝试使用 NuGet画廊| PCOMMLib 1.0.1 [ ^ ] 可在此处获得: Vrzasq / PCOMMLib - Bitbucket [ ^ ]
更多推荐
HACL终端仿真器自动化:ECLPS对象和线程
发布评论