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

スクリプト ファイルを 1 回だけロードするために、IronRuby.Ruby.RequireFile を使用できます。

たとえば、次の行は、標準ライブラリ フォルダーから CSV ライブラリを読み込みます。

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

それが役に立てば幸い、

シェイ。

于 2009-10-20T12:46:00.757 に答える