I’m gonna spare you the details of the edge-case issues I ran into (in a nutshell: they involve loading assemblies from other directories that load other assemblies from yet other directories causing things to act real strange in DLR-land), but here a little trick…
If for some reason you would like to load/require an assembly in IronRuby in the Load and not the LoadFrom context then instead of just doing this (which is, by the way, in most cases, the best thing to do):
require '.\some\path\assembly.name.dll'
do something like this:
def do_in(working_dir) dir = Dir.pwd Dir.chdir working_dir yield Dir.chdir dir end do_in '.\some\path' do require 'assembly.name' end
Works like a charm…
Note: If the code in your loaded assembly loads other things at runtime, you’ll have to do that work in the do_in
block as wel, of course. Like this:
do_in '.\some\path' do require 'Assembly.Name' Assembly::Name::Type.new(foo, bar) # this loads more stuff at runtime end