I have a problem loading an external dll using Python via Python for .NET. I tried different methodologies after stackoverflow and similar. I will try to generalize the situation and describe all the steps that I have taken.
I have a dll so named for example. Test.NET.dll. I checked with dotPeek and I can see by clicking on it, x64 and the .NET Framework v4.5. On my computer, I installed .Net Framework 4.
I also installed Python for .NET in different ways. I think the best one is to download .whl from this LINK site. I downloaded and installed: pythonnet-2.0.0.dev1-cp27-none-win_amd64.whl. I can imagine that it will work for .NET 4.0, as it requires Microsoft.NET Framework 4.0.
Once I installed everything, I can execute the following commands:
>>> import clr >>> import System >>> print System.Environmnet.Version >>> print System.Environment.Version 4.0.30319.34209
It seems to work. Then I tried to load my dll by typing the following commands:
>>> import clr >>> dllpath= r'C:\Program Files\API\Test.NET' >>> clr.AddReference(dllpath) Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> clr.AddReference(dllpath) FileNotFoundException: Unable to find assembly 'C:\Program Files\API\Test.NET'. at Python.Runtime.CLRModule.AddReference(String name)
I also tried adding '.dll' to the end of the path, but nothing changed. Then I also tried various solutions, as described in LINK , LINK , LINK and much more .... Unfortunately, this does not work, and I get different errors. I know that IronPython exists, but I tried to avoid using it.
Thank you for your help!
source share