python Comtypes CreateObject出错
我在COM上注册了一个C#dll,我正在尝试使用comtypes在Python代码中使用它,该代码在我正在开发C#dll的机器上运行得非常好,但当部署到另一台具有所有必需文件的机器上时无法加载 这是我得到的错误python Comtypes CreateObject出错,python,dll,createobject,windowserror,comtypes,Python,Dll,Createobject,Windowserror,Comtypes,我在COM上注册了一个C#dll,我正在尝试使用comtypes在Python代码中使用它,该代码在我正在开发C#dll的机器上运行得非常好,但当部署到另一台具有所有必需文件的机器上时无法加载 这是我得到的错误 Traceback (most recent call last): File "C:\Python27\Lib\site-packages\bellagio\DriverManager\audiotest\apx525\apx525_Wrapper.py", line 257, i
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\bellagio\DriverManager\audiotest\apx525\apx525_Wrapper.py", line 257, in <module>
c._Connect()
File "C:\Python27\Lib\site-packages\bellagio\DriverManager\audiotest\apx525\apx525_Wrapper.py", line 51, in _Connect
self.apx525 = CreateObject("APxWrapper.APxWrapper",None,None,apx.IAPxWrapper)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 235, in CreateObject
obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\__init__.py", line 1145, in CoCreateInstance
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
File "_ctypes/callproc.c", line 936, in GetResult
WindowsError: [Error -2147024894] The system cannot find the file specified
请注意,该文件夹有3个文件ApxWrapper.tlb.ApxWrapper.dll和一个依赖项dll。
GetModule工作正常,pyton文件在comtypes.gen文件夹中生成
对此有任何提示,我们将不胜感激
Sanjay问题在于两台机器中引用的.Net dll版本,Python不知何故没有给出完整的错误详细信息,我可以通过运行我编写的示例c#应用程序来解决问题,抛出的c#异常包含了所有必要的信息。问题在于两台机器中引用的.Net dll版本,Python不知何故没有给出完整的错误详细信息,我可以通过运行我编写的示例c#应用程序来解决这个问题,抛出的c#异常包含了所有必要的信息
try:
from comtypes.client import CreateObject,GetModule, Constants, GetEvents
from comtypes import COMError
GetModule("P:\\Share\\Test\\TestBed\\Bellagio\\dll\\APxWrapper.tlb")
from comtypes.gen import APxWrapper as apx
except:
tblog.warnLog("Need to install comtypes package, AP driver not imported")
class IAPxWrapper_Impl(object):
def __init__(self):
self.apx525 = None
self.activeSignalPath = ''
self.activeMeasurement = ''
def _Connect(self):
self.apx525 = CreateObject("APxWrapper.APxWrapper",None,None,apx.IAPxWrapper)
self.apx525._GUIVisible = True;
return True
c = IAPxWrapper_Impl()
c._Connect()