0

I would like to import a dll file under Ubuntu 20.04 in Python 3.8.

I tried it with mono and pythonnet as it was recommended in another answer:

import clr
clr.AddReference(dll_path)
import image3dAPI

but I got the following error:

Invalid Image

If I check the dll with mono:

$ monop -r Image3dLoaderGe.dll

It says:

Could not load Image3dLoaderGe.dll

Is there any other way to use this dll under Linux (even if it is not an "Assembly DLL file")?

I read about WineHQ, but I didn't find any sample code where they did something similar.

Balint
  • 43
  • 6

1 Answers1

1

Few possible issues here:

  1. there are several libs that goes by the import name clr. like IronPython (https://ironpython.net/documentation/dotnet/) or clr (https://pypi.org/project/clr/) - you need to make sure you install pythonnet (which is also imported with import clr) so install with: pip install pythonnet
  2. the importing of the class from the lib should include the namespace, like so: from <namespace> name import <class name>. see pythonnet tutorial for more info: https://pypi.org/project/pythonnet/
  3. not all DLLs are supported in Linux. for example, if it's a C# DLL, it must be built with .NET core or else it would only work with Windows OS.
Nissim
  • 31
  • 4
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 09 '22 at 04:38