Search code examples
c#ironruby

Is there any free C# component class to provide means for C# code to load IronRuby code from files?


I learned here stackoverflow that you can easily achieve bidirectional access between c# of a Win form and javascript loaded in a web browser control. Then let me ask whether you can do similar bidirectional access between C# and IronRuby using any free C# component? Although I searched how to do bidirectional access between the 2 languages in .net platform,any of them does not bring the same simpleness as the way I described first.


Solution

  • @svick is right but I just want to elaborate with an example where data flows from C# to IronRuby and back.

    var engine = Ruby.CreateEngine();
    engine.ExecuteFile("../../test.rb");
    dynamic ruby = engine.Runtime.Globals;
    dynamic hello = ruby.Hello.@new("Hello from Ruby!");
    hello.set_text(textBox1);
    

    and the Ruby code in test.rb

    class Hello
      def initialize text
        @text = text
      end
    
      def set_text text_box
        text_box.Text = @text
      end
    end
    

    PS. After installing IronRuby from http://ironruby.net/download/ I, for some reason, could only find the IronRuby.dll, IronRuby.Libraries.dll, and Microsoft.Scripting.dll in C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\ DS.