Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python clr.AddReference(';示例文件';)-找不到程序集_Python_.net_Python 2.7_Ironpython - Fatal编程技术网

Python clr.AddReference(';示例文件';)-找不到程序集

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

我正在尝试使用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.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,这里的信息并不充分,但至少有两件事需要考虑:

  • 您没有设置其他与Python相关的环境变量。例如,使用虚拟环境或让Python指向其他地方。如果设置了
    PYTHONHOME
    PYTHONPATH
  • 您试图加载的DLL的位大小与Python解释器的位大小相同。即。如果您有一个64位Python,您可能需要加载(但不总是)一个64位DLL
  • 在您的字符集中正确读取路径规范。
    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