簡體   English   中英

win32com分發32位版本的TestStand

[英]win32com Dispatch the 32 bit version of TestStand

我有一個連接到TestStand的python腳本,並從.seq(序列)文件中檢索某些數據。

import win32com.client
import pythoncom
TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
Seqfile = TestStandEngine .GetSequenceFileEx("Seq_File.seq")
Main = Seqfile.GetSequenceByName("MainSequence") #Get's the main sequence of the file

我已經安裝了x32和x64版本的Test Stand 2014,腳本運行得很好。 卸載x64版本后(因為不需要它),腳本現在顯示此錯誤:

Traceback (most recent call last):
  File "C:\ts\Main.py", line 9, in <module>
    TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
  File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)

經過一些研究,我認為我知道是什么原因引起的問題,但是我找不到任何解決方法。

-我計算機上的Python安裝是32位

>>> import platform
>>> platform.architecture()
('32bit', 'WindowsPE')

-我的計算機上唯一安裝的Test Stand是32位版本。

-操作系統:Windows x64位操作系統

這是我的猜測:我認為,當它分派Teststand.Engine時,它將嘗試使用不再安裝的x64版本。 我嘗試通過添加clsctx參數,但結果相同:

win32com.client.Dispatch("TestStand.Engine",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)

有什么辦法可以“強制”它啟動32位版本? 如果TestStand在32bit上並且Python在32bit上,是否不應該返回應該與python 32bit一起使用的32bit COM對象?

更新:因此,在PowerShell中運行此命令后 ,它返回了所有有效COM名稱的列表,但“ Teststand.Engine ”不在列表中。 列表中唯一與TestStand相關的對象是TestStand.ExLauncher(我可以分派,但它的屬性/用途與TestStand.Engine不同

通過重新安裝TestStand解決了該問題。 (我知道重新安裝可以解決問題,但我希望不必重新安裝它,因為它會影響多個配置)

問題是,當我卸載TestStand x64版本時,卸載程序認為我將完全卸載TestStand,並且很可能刪除了一些包含“ TestStand.Engine”說明的注冊表項。重新安裝x32位版本后,它可以正常工作。

您是否嘗試過使用版本相關的界面,即

TestStandEngine = win32com.client.Dispatch("TestStand.Engine.1")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM