pythonnet / pythonnet/clr-loader

netfx loader with LOAD_LIBRARY_SEARCH_USER_DIRS

未关闭
#77 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
42
派生
32
平均合并
14 小时 1 分钟
30 天内合并 PR
1

描述

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.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先复现这样一段 Python 代码:在导入 clr 之前调用 SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS)。检查 clr_loader 的 DLL 加载路径及其 ffi/dlls/amd64 目录,然后验证在此 Windows 搜索模式下导入 clr 可以正常工作,而不依赖所报告的变通方案。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
devtools, operating-systems
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。