[IronPython] Loading IronPython assemblies dynamatically

Ben Hall ben2004uk at googlemail.com
Sat May 17 02:27:35 CEST 2008


I have an interesting problem and I was wondering if you would be able
to help. I am trying to load the IronPython assemblies dynamically
(IronPython.dll and IronPython.Modules.dll),  and what I am doing is

Assembly.LoadFile(Path.Combine(Settings.BinDirectory, assembly));

I'm then creating the Runtime and the Engine after the assemblies have
loaded.  But when I try runtime.GetEngine I get the following

  ----> System.IO.FileNotFoundException : Could not load file or
assembly 'IronPython, Version=, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
system cannot find the file specified.
	at Microsoft.Scripting.Runtime.ScriptDomainManager.LanguageRegistration.LoadLanguageContext(ScriptDomainManager
	at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageContext(Type
	at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngine(Type

Ok, so I hooked up to the Assembly Resolve event, and when I get to
get the engine it fires off.

Assembly name passed into the AssemblyResolve event is:
IronPython, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35

However, the assembly I am loading is this:
IronPython, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Same with Modules:
IronPython.Modules, Version=, Culture=neutral,

After I reload the assembly (using the same Assembly.Load) everything
works fine!

Why is this? I would prefer not to have to load my assemblies twice.
These the assemblies I downloaded from CodePlex.


More information about the Ironpython-users mailing list