[IronPython] Add reference to .dll located in above directory

cenovsky at bakalari.cz cenovsky at bakalari.cz
Thu May 20 09:37:19 CEST 2010


Hi all,
I have the following directory structure:

root
|-- PythonModules.dll
|-- module
      |-- foo.py

I want to add reference to PythonModules.dll  from foo.py. I have the  
compiled Python libraries there I need to use in foo.py.

I have not successfully make this work with sys.path:

import clr
import sys
sys.path.append('root')      # this is full path to root
clr.AddReference('PythonModules')

Traceback (most recent call last):
   File "C:\test\modul\t.py", line 4, in <module>
IOError: System.IO.IOException: Could not add reference to assembly  
PythonModules
    at  
Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[]  
args, Boolean& shouldOptimize)
    at  
IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`2.Call1(CallSite site, CodeContext context, TFuncType func, T0  
arg0)
    at  
System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site,  
T0 arg0, T1 arg1, T2 arg2)
    at __main__$1.__main__(FunctionCode $functionCode) in  
C:\test\modul\t.py:line 14
    at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
    at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
    at IronPython.Hosting.PythonCommandLine.RunFileWorker(String fileName)
    at IronPython.Hosting.PythonCommandLine.RunFile(String fileName)>>>

I get the same error when I use clr.AddReferenceToFile('PythonModules.dll').

The only way how could I make this work is the following:

import clr
import sys
clr.AddReferenceToFileAndPath('..\\PythonModules')

This is not suitable for me as I want to run foo.py from different  
directories.

Is it a bug? Or do I something wrong?

--
-- Lukáš




More information about the Ironpython-users mailing list