clr-loader
clr-loader copied to clipboard
netfx loader with LOAD_LIBRARY_SEARCH_USER_DIRS
If the win32 API SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS) is used, the default clr_loader doesn't work.
import ctypes
from ctypes import wintypes
dll = ctypes.CDLL("Kernel32.dll")
dll.SetDefaultDllDirectories.argtypes=[wintypes.DWORD]
LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400
dll.SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS)
import clr # <---- crash
This search mode is documented here
It is used in the python distribution from the windows store (although I don't know if this issue is reproducible there) as well as some embedders of Python.
I tried the following as a workaround: import os os.add_dll_directory(r"C:\Windows\Microsoft.NET\Framework64\v4.0.30319") os.add_dll_directory(r"C:\path\to\python\env\site-packages\clr_loader\ffi\dlls\amd64")
And it didn't work.