[IronPython] Feature request: Make assembly loading strategy configurable.

Jeff Brown Jeff at ingenio.com
Mon Feb 19 10:00:11 CET 2007


Iron Python installs a rather dragonic AssemblyResolve hook.  It uses
Assembly.LoadFile to try to load an Assembly from the path when
resolution fails.  I would prefer if Assembly.LoadFrom were provided at
least as an option, if not just made the standard behavior (once again).

The problem in my case is that Iron Python is linking to an application
that installs its own AssemblyResolve hook based on LoadFrom.  Because
LoadFrom and LoadFile Assemblies are tracked separately it happens that
two copies of the same Assembly are loaded but they have incompatible
types so the application blows up.  What's more, there may actually be
several identical copies of the same assembly floating around the search
path.  This is because the application consists of an assortment of
plugin folders with locally copied (rather than shared) binaries.

Here's my current workaround.  Ugly huh?


import System;
System.AppDomain.CurrentDomain.remove_AssemblyResolve(System.Delegate.Cr
eateDelegate(System.ResolveEventHandler, clr,
"CurrentDomain_AssemblyResolve"))
def AssemblyResolveWithLoadFrom(sender, e):
    try:
        return System.Reflection.Assembly.LoadFrom(e.Name + ".dll")
    except:
        return None
System.AppDomain.CurrentDomain.add_AssemblyResolve(AssemblyResolveWithLo
adFrom)

Jeff.



More information about the Ironpython-users mailing list