【问题标题】:Dispatch CANoe using python COM使用 python COM 调度 CANoe
【发布时间】:2016-11-23 17:59:40
【问题描述】:

我正在尝试使用 python win32com 打开 CANoe 应用程序,但出现以下错误

Traceback (most recent call last):
  File "C:\Users\20044033\Desktop\test.py", line 2, in <module>
   xl = win32com.client.Dispatch ('CANoe.Application')
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python27\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)

com_error: (-2147221005, '无效的类字符串', None, None)

而其他应用程序(如 excel)则没有此类错误。 从其他 stackoverflow 答案中,我了解到只能访问 COM 注册的应用程序。

如何将 CANoe 添加到已注册的 COM 对象列表中?

【问题讨论】:

  • 不提供MCVE 无济于事,但据我所知,CANoe 在安装过程中会自行注册,所以我怀疑这是原因,除非您在安装过程中出现问题。
  • 您找到解决方案了吗?

标签: python python-2.7 com win32com canoe


【解决方案1】:

早上好,实际上我正在做同一个项目,我曾经遇到过和你一样的问题,你只需要检查你的 CANoe 配置的名称并在 python 代码中输入正确的路径这是我的代码和测量在 CANoe 中设置。 祝你好运!!

【讨论】:

  • 你应该把它作为评论,这不是一个真正的答案,可能会与真正的答案混淆;)
  • 你说这是我的代码,然后什么都不提供。此外,您应该能够在不指定任何配置文件的情况下启动 CANoe(使用唯一的 win332com.client.Dispatch("CANoe.Application")。
  • 添加到我之前的评论:我猜有一个警告 - 如果您不提供任何配置,CANoe 必须知道默认的配置加载。
猜你喜欢
  • 2020-08-11
  • 2020-05-16
  • 2021-03-06
  • 2019-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
相关资源
最近更新 更多