c# - Load DLL file and Call Functions in Python -
i have problem loading dll file , calling functions in python. have tried lot of tutorials, still can't figure out how works. class export dll file. use simple c# code.
namespace democlasslib { public class clib { public int increment(int x) { return x + 1; } } } after building c# code, dll file called "democlasslib.dll". use ctypes load dll file. okay until now.
from ctypes import * mydll = windll('d:\\resources\\democlasslib\\bin\\debug\\democlasslib.dll') starting point, can't continue. commands have tried failed.
n = c_int(1) mydll.increment(n) it keeps on showing me errors. how can call method "increment()" in python? , how can pass input , retrieve output that? new python. can me please? appreciated if can provide me source code tutorial.
you can't ctypes because there no symbol in binary called "increment", increment method member of class. if c++ name mangled. c# don't mangled name in symbol table because code interpreted .net framework.
if must reason interface c# library may want consider trying ironpython (http://ironpython.net/) python running on .net framework full access clr. comment above suggesting exposing com interface work.
Comments
Post a Comment