Skip to content

Commit d7654a1

Browse files
committed
fixed issue with .Net 9
1 parent 3846893 commit d7654a1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pythonnet_minimal.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Set runtime config files
2-
import pythonnet, clr_loader, os
2+
import pythonnet, os, sys
33
bin_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)),'bin','Debug','net9.0')
4+
if bin_folder not in sys.path:
5+
sys.path.insert(0, bin_folder)
6+
47
runtime_config_path = os.path.join(bin_folder,'pythonnet_minimal.runtimeconfig.json')
5-
pythonnet.set_runtime(clr_loader.get_coreclr(runtime_config=runtime_config_path))
8+
pythonnet.load(runtime="coreclr",runtime_config=runtime_config_path)
69

7-
# Load library
810
import clr
9-
dll_filepath = os.path.join(bin_folder,'pythonnet_minimal.dll')
10-
clr.AddReference(dll_filepath)
11+
clr.AddReference("pythonnet_minimal")
1112

1213
# Register Encoder (optional)
1314
import Python.Runtime

0 commit comments

Comments
 (0)