3

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'
1
  • 1
    i was able to import WinDLL, are you sure that you are giving the full path to the pythontest.dll? Commented May 26, 2018 at 8:09

1 Answer 1

2

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()

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your question. But now I run into the error "invalid ELF header".
@Christian Ah I was hoping you had found a way around that. Have you seen: stackoverflow.com/questions/20762142/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.