0

我想将当前应用程序的加载 dll 自动添加到 Ironruby 引擎中,这样每次执行脚本时我都不会再指定“require”脚本。

非常感谢。

4

2 回答 2

2

我在 2008 年 9 月使用ScriptRuntime.LoadAssembly. 这是我的原始代码

// 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);
}
于 2009-11-03T22:36:38.747 回答
1

您可以使用 IronRuby.Ruby.RequireFile 来只加载一次脚本文件。

例如,下一行从标准库文件夹加载 CSV 库:

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

希望能帮助到你,

谢伊。

于 2009-10-20T12:46:00.757 回答