I have a handfull of .dll files with classes designed to control an external device connected to my desktop via ethernet. I'd like to import these classes to python and use their member functions / variables etc to control the device.
I have looked at a number of options including:
-ctypes (which seemed to work well for functions but not classes). Here "DotNet\Aerotech.Ensemble.dll" is my dll library, and "Network" is a class in that library with a member function "Connect". The library loads, but I can't access the class...
>>> from ctypes import *
>>> lib = cdll.LoadLibrary('DotNet\Aerotech.Ensemble.dll')
>>> lib.Network.Connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\ctypes\__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "C:\Python26\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Network' not found
-IronPython / Python for .Net but these seem to be seperate languages altogether and I want to be able to do everything from one place (python).
-SWIG. The SWIG documentation seems to indicate that it can handle importing classes, but also seems to require C++ code and or header files (which I dont have) to be wrapped for use as a python module.
I'm a beginner and fairly lost here so any help is appreciated!
EDIT:
@SvenMarnach: I had a look at IronPython and was able to get it working with my dll files, but I want to do this in Python since I am already doing a lot of things in that language. I want to integrate these dll functions or classes or whatever into existing python programs.
In getting IronPython working, however, I stumbled back accross Python for .NET which claims to be able to install .Net awareness to existing python installations...This works (ie I can access the dll files and control my device) if I use it in the directory which I downloaded the python for .NET files to, but if I try it in some other directory (remembering to append the python.net dir to the sys.path), you get an error ImportError: dynamic module does not define init function (initclr)