Python clr.AddReference(';示例文件';)-找不到程序集
我正在尝试使用clr模块中的AddReference('example\u file')方法添加对“example\u file.dll”的引用:Python clr.AddReference(';示例文件';)-找不到程序集,python,.net,python-2.7,ironpython,Python,.net,Python 2.7,Ironpython,我正在尝试使用clr模块中的AddReference('example\u file')方法添加对“example\u file.dll”的引用: >>>import clr >>>clr.AddReference('example_file') 结果我得到: Traceback (most recent call last): File "<stdin>", line 1, in <module> System.IO.FileNot
>>>import clr
>>>clr.AddReference('example_file')
结果我得到:
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)
此外,由于:
>>>clr.FindAssembly('example_file')
我明白了
这个问题每天都在发生。我很困惑,因为它以前工作得很好-我不知道这会有什么影响。
我使用的是Windows 7 x64、python 2.73和.Net framework 4,这里的信息并不充分,但至少有两件事需要考虑:
PYTHONHOME
和PYTHONPATH
sys.path.append(r“C:\ProgramFiles\SomeApi”)
为了明确起见,您是否尝试过使用
clr.AddReferenceToFileAndPath
?是否根据.NET 4编译example_file.dll
?看到了吗?与“以前”相比有什么变化吗?每个人都可能会同意,并强烈建议您远离十年前过时的Python2.7,实现Py3.7+的飞跃。AttributeError:模块“clr”没有属性“AddReference”
>>>clr.FindAssembly('example_file')
u'example_file.dll