![](https://secure.gravatar.com/avatar/424a8f03889e3ffbf9ed57adb1fc41cc.jpg?s=120&d=mm&r=g)
Dave Hirschfeld <dave.hirschfeld@gmail.com> writes:
Brandon Craig Rhodes <brandon@...> writes:
>>> 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
Works for me ... but I was in the same directory as the dll. Are you in the same directory?
Yes, I am in the same directory; and I just double-checked before replying. :-)
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)
Ah! That gives a much more informative error message: Traceback (most recent call last): File "test.py", line 28, in <module> Reflection.Assembly.LoadFile(r'C:\Users\brandon\dev\pythonnet\Brandon.dll') System.BadImageFormatException: This assembly is built by a runtime newer than t he currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x801 3101B) at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String path) Well, drat. A newer runtime? So in response to this, I have just gone through and removed all traces of earlier Visual Studios and .NET on my computer, leaving only 2010 and 4.0 in my list of installed programs, and then checked out a fresh copy of Python for .NET and rebuilt it with "msbuild" and then tried again. Unfortunately I get the same error message. Is the problem that stock Python 2.6 is built with an older runtime than the one I am using to build my DLL? What should I try next? Thanks for the help! -- Brandon Craig Rhodes brandon@rhodesmill.org http://rhodesmill.org/brandon