Unable to Load COM object DLL #1739
Unanswered
GopinathRamajayam
asked this question in
Q&A
Replies: 3 comments
|
Added .Net version |
0 replies
|
I worried you trying to load a 32bit dll with 64bit python, you will need 32bit python?(or 64bit dll?) |
0 replies
|
Thank you for your input, Kazu Narita. The DLLs are 32-bit. So, I have tried using 32bit python and Pythonnet. It still throws the same error. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Environment
Details
I am trying to load DLL (add a reference to COM objects) from Simatic Step 7 Manager.
From the documentation :
In order to use the command interface, you must make two entries for the project. To do so, select in Visual Studio the menu command Project > Add Reference > COM. You can find the accompanying DLLs under STEP7/S7bin/s7abatcx.dll and STEP7/S7bin/s7hcom_x.dll.
My Code :
import sys
visualStudio_dll = r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\envdte.dll'
clr.AddReference(str(visualStudio_dll))
from EnvDTE import DTE
S7ABATCX_dll = r'C:\Program Files (x86)\Siemens\Step7\S7BIN\S7ABATCX.DLL'
S7hcom_x_dll = r'C:\Program Files (x86)\Siemens\Step7\S7BIN\S7hcom_x.dll'
clr.AddReference(str(S7ABATCX_dll))
clr.AddReference(str(S7hcom_x_dll))
Things I tried
https://stackoverflow.com/questions/13259617/python-for-net-unable-to-find-assembly-error
I tried a few things from this StackOverflow post. Unfortunately, it didn't work out.
There is no Block for the DLLs.
I tried without .dll in the path
S7ABATCX_dll = r'C:\Program Files (x86)\Siemens\Step7\S7BIN\S7ABATCX'
clr.AddReference(str(S7ABATCX_dll))
I tried adding the sys path for the dll.
import sys
sys.path.append(os.path.dirname(S7ABATCX_dll))
sys.path.append(r"C:/Program Files (x86)/Siemens/Step7/S7BIN")
Works in C#
I am able to add this COM (S7ABATCX.DLL and S7hcom_x.dll) reference in C# Visual Studio 2019. But I am not able to do it in Python using PythonNet.
Traceback
The error message I am getting,
'''
Traceback (most recent call last):
File "C:\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 3, in
System.IO.FileNotFoundException: Unable to find assembly 'C:\Program Files (x86)\Siemens\Step7\S7BIN\S7ABATCX.DLL'.
at Python.Runtime.CLRModule.AddReference(String name)
'''
All reactions