Brandon Craig Rhodes <brandon@...> writes:
I have only gotten as far as trying to AddReference() my new DLL, but have not been able to get it to succeed.
>>> import clr >>> print clr.FindAssembly('Brandon') C:\Users\brandon\dev\pythonnet\Brandon.dll >>> clr.AddReference('Brandon') ... System.IO.FileNotFoundException: Unable to find assembly 'Brandon'. at Python.Runtime.CLRModule.AddReference(String name) in c:\Users\brandon\dev\pythonnet\src\runtime\moduleobject.cs:line 370
You can see that, oddly enough, Python can find the assembly, but cannot create a reference to it.
Works for me: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.10 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [2]: pwd Out[2]: 'C:\\temp\\PythonDotNET' In [3]: ls Volume in drive C has no label. Volume Serial Number is 90C1-4729 Directory of C:\temp\PythonDotNET 28/05/2010 08:35 <DIR> . 28/05/2010 08:35 <DIR> .. 26/10/2009 14:03 5,632 FactoryPattern.dll 1 File(s) 5,632 bytes 2 Dir(s) 188,252,098,560 bytes free In [4]: import clr In [5]: clr.AddReference('FactoryPattern') Out[5]: <System.Reflection.Assembly object at 0x03798DA0> ...but I was in the same directory as the dll. Are you in the same directory? What happens if you try to put the full path? e.g. clr.AddReference(r'C:\temp\PythonDotNET\FactoryPattern') If that doesn't work does using Assembly.LoadFile work? e.g. from clr import System from System import Reflection full_filename = r'C:\temp\PythonDotNET\FactoryPattern.dll' Reflection.Assembly.LoadFile(full_filename) HTH, Dave