up vote 0 down vote favorite
share [g+] share [fb]

I want to automatically add loaded dll of the current application into ironruby engine so that each time I execute a script I won't specify the "require" script anymore.

Thanks a lot.

link|improve this question

69% accept rate
feedback

2 Answers

You can use IronRuby.Ruby.RequireFile in order to load a script file only once.

For example, the next line loads the CSV library from the standard library folder:

IronRuby.Ruby.RequireFile(engine, @"D:\IronRuby\lib\ruby\1.8\csv.rb");

Hope it helps,

Shay.

link|improve this answer
The latest version has the RequireRubyFile but I don't know if this supports dll's. I'll go check it out. – Marc Vitalis Oct 20 '09 at 23:55
feedback

I did this in September 2008 using ScriptRuntime.LoadAssembly. Here's my original code

// this part may have changed, there's probably a different
// way to get the ScriptRuntime from the RubyEngine or somesuch
var runtime = new ScriptRuntime( Ruby.CreateRuntimeSetup() ); 

// give ruby access to all our assemblies
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
    runtime.LoadAssembly(assembly);
}
link|improve this answer
Yep, Orion is correct; ScriptRuntime#LoadAssembly is the answer – Jimmy Schementi Dec 15 '09 at 8:39
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.