Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using .NET Core Library in Linux Python

I wrote a C# library in linux with .NET Core. Now I want to use it in python. Has someone experience with this topic? Is this even possible?

I tried to use

import ctypes as ct
lib = ct.WinDLL("PythonTest.dll")

but I run in this error

 Traceback (most recent call last):
     File "<input>", line 1, in <module>
 AttributeError: 'module' object has no attribute 'WinDLL'
like image 992
Christian Avatar asked Jan 18 '26 14:01

Christian


1 Answers

Please see the documentation

On Linux, it is required to specify the filename including the extension to load a library, so attribute access can not be used to load libraries. Either the LoadLibrary() method of the dll loaders should be used, or you should load the library by creating an instance of CDLL by calling the constructor:

WinDLL() is for Windows on Linux you need to use .LoadLibrary() or CDLL()

like image 143
Xantium Avatar answered Jan 21 '26 05:01

Xantium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!