[Python.NET] how can I build an assembly I can AddReference()?
Brandon Craig Rhodes
brandon at rhodesmill.org
Fri May 28 15:07:08 CEST 2010
Dave Hirschfeld <dave.hirschfeld at gmail.com> writes:
> Brandon Craig Rhodes <brandon at ...> writes:
>> >>> import clr
>> >>> print clr.FindAssembly('Brandon')
>> >>> 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
> 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'
Ah! That gives a much more informative error message:
Traceback (most recent call last):
File "test.py", line 28, in <module>
System.BadImageFormatException: This assembly is built by a runtime newer than t
he currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x801
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 at rhodesmill.org http://rhodesmill.org/brandon
More information about the PythonDotNet