Skip to content

netfx loader with LOAD_LIBRARY_SEARCH_USER_DIRS #77

@koubaa

Description

@koubaa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions