小编use*_*461的帖子

clr.AddReference('example_file') - 无法找到程序集

我正在尝试使用 clr 模块中的 AddReference('example_file') 方法添加对“example_file.dll”的引用:

>>>import clr
>>>clr.AddReference('example_file')
Run Code Online (Sandbox Code Playgroud)

结果我得到:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
System.IO.FileNotFoundException: Unable to find assembly 'example_file'.

at Python.Runtime.CLRModule.AddReference(String name)
Run Code Online (Sandbox Code Playgroud)

所有文件都位于当前工作目录中,sys.path 如下所示:

>>> sys.path
['', 'C:\\Python27\\lib\\site-packages\\pip-1.2.1-py2.7.egg', 'C:\\Python27', 'C
:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27\\lib\\
site-packages', 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\']
Run Code Online (Sandbox Code Playgroud)

此外,由于:

>>>clr.FindAssembly('example_file')
Run Code Online (Sandbox Code Playgroud)

我明白了

u'example_file.dll 
Run Code Online (Sandbox Code Playgroud)

问题一天天出现。我很困惑,因为它以前工作得很好 - 我不知道什么会对此产生影响。我正在使用 Windows 7 x64、python 2.73 和 .Net Framework 4

.net python ironpython python-2.7

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

.net ×1

ironpython ×1

python ×1

python-2.7 ×1