I want to access a function my_function() present in a c# file which is compiled into a .net dll - abc.dll.
C# file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public class Class1
{
public string my_function()
{
return "Hello World.. :-";
}
}
}
After compiling the above code to abc.dll
Using the below python trying to access my_function()
import ctypes
lib = ctypes.WinDLL('abc.dll')
print lib.my_function()
Above code throws error
lib.my_function() Traceback (most recent call last): File "", line 1, in File "C:\Anaconda\lib\ctypes__init__.py", line 378, in getattr func = self.getitem(name) File "C:\Anaconda\lib\ctypes__init__.py", line 383, in getitem func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'my_function' not found
print lib.Test.Class1.my_function()?