I'm attempting to import a c# module into Python using python.NET under Anaconda
This has been installed using pip install pythonnet which reported "Successfully installed pythonnet-2.5.2"
From there with python it should be possible to do something like the following which isn't working properly. Jetbrains dotPeek can see the module, and calls to standards Windows dlls work fine. What am I doing wrong?
clr.AddReference(R'C:\Program Files (x86)\UVtools\UVtools.Core.dll')
from UVtools.Core import About
>>ModuleNotFoundError: No module named 'UVtools'
# never gets here:
print(About.Software)
This works fine:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form
form = Form()
print(dir(form))
>> ['AcceptButton', ...
This also doesn't work (trying to access the same dll in a different way)
import System
uvTools = System.Reflection.Assembly.LoadFile(R'C:\Program Files (x86)\UVtools\UVtools.Core.dll')
print(uvTools.FullName)
print(uvTools.Location)
>>UVtools.Core, Version=2.8.4.0, Culture=neutral, PublicKeyToken=null
>>C:\Program Files (x86)\UVtools\UVtools.Core.dll
# But the following all fail with the same fundamental error:
print(uvTools.UVtools.Core.About)
print(uvTools.Core.About)
print(uvTools.About)
>>AttributeError: 'RuntimeAssembly' object has no attribute 'About'
JetBrains dotPeek can see the modules, which to me would have implied it's not an issue with the dll.
I did see elsewhere that if trying to use ctype then you need to include "[DllExport("add", CallingConvention = CallingConvention.Cdecl)]" in the c# basecode, but I don't think this applies to python.NET clr calls