[IronPython] Loading IronPython assemblies dynamatically
Ben Hall
ben2004uk at googlemail.com
Sat May 17 02:27:35 CEST 2008
Hello,
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
this:
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
exception:
----> System.IO.FileNotFoundException : Could not load file or
assembly 'IronPython, Version=2.0.0.2000, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
system cannot find the file specified.
at Microsoft.Scripting.Runtime.ScriptDomainManager.LanguageRegistration.LoadLanguageContext(ScriptDomainManager
manager)
at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageContext(Type
type)
at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngine(Type
languageContextType)
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=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35
However, the assembly I am loading is this:
IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Same with Modules:
IronPython.Modules, Version=2.0.0.2000, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
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.
Thanks
Ben
More information about the Ironpython-users
mailing list