Replies: 1 comment 4 replies
-
The runtime version is just not implemented (yet) for .NET Framework. If .NET 4.8 is installed, it should be used (I think :)). You could try to modify |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use pythonnet.3.0.1 to load/use a DLL in Python code that is compiled to require a .NET 4.8 (Target Framework: 4.8). Loading DLL doesn't work (ModuleNotFoundError: No module named 'DllThatRequires4.8'). I'm able to load a DDL from the same path that doesn't require .NET 4.8 (Target Framework: 4.0).
I suspect my issue is that pythonnet doesn't target the 4.8 runtime (see undefined runtime version in code output), how can I configure it to do so? I've found some examples of loading a .NET core with config: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/#runtimeconfigjson, but nothing on legacy .NET.
My Windows Server 2016 machine has a .NET 4.8 installed, as shown under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Version: 4.8.03761
Using Windows server 2016, python 3.10.8 32-bit, pythonnet 3.0.1
My code (simplified):
from pythonnet import get_runtime_info
sys.path.append('path\to\dll\folder')
import clr
print(get_runtime_info())
clr.AddReference('DllThatRequires4.8')
from DllThatRequires4.8 import something #this doesn't work
clr.AddReference('DllThatDoesNotRequire4.8')
from DllThatDoesNotRequire4.8 import something # this works
code output:

....
File "steps\Automation\client.py", line 8, in
from DllThatRequires4.8 import something
ModuleNotFoundError: No module named 'DllThatRequires4.8'
Beta Was this translation helpful? Give feedback.
All reactions