you might want to move the executefile method var url = "http://www.google.com.com";
var engine = IronRuby.Ruby.CreateEngine(); var paths = new List<String>(); paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib"); paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby\1.8"); paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby"); paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\1.8"); engine.SetSearchPaths(paths); var obj = engine.Runtime.Globals.GetVariable("ScreenScraper"); engine.ExecuteFile("../../screenscraper.rb"); var screenScraper = engine.Operations.CreateInstance(obj); var html = engine.Operations.InvokeMember(screenScraper, "scrape", url); Console.WriteLine(html); --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero - Mob: +32.486.787.582 Web: http://whiterabbitconsulting.eu - http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) Microsoft IronRuby/C# MVP On Mon, Mar 1, 2010 at 3:25 PM, Mohammad Azam <li...@ruby-forum.com> wrote: > So, I added the paths that you provided in my C# code since I am trying > to execute the .rb file from C#. Here is the complete code: > > static void Main(string[] args) > { > var url = "http://www.google.com.com"; > > var engine = IronRuby.Ruby.CreateEngine(); > var scope = engine.ExecuteFile("../../screenscraper.rb"); > > var paths = new List<String>(); > paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib"); > > paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby\1.8"); > paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby"); > paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\1.8"); > > > engine.SetSearchPaths(paths); > > > var obj = > engine.Runtime.Globals.GetVariable("ScreenScraper"); > > var screenScraper = engine.Operations.CreateInstance(obj); > > var html = engine.Operations.InvokeMember(screenScraper, > "scrape", url); > > Console.WriteLine(html); > > } > > > When I run the application I get the following error: > > > Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load > -- open-u > ri > at > Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame > fram > e) > at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame > frame) > at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 > arg0, T1 a > rg1) > at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean > bindGlobals) > at IronRuby.Runtime.RubyScriptCode.Run(Scope scope) > at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink > errorSink) > at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope > scope) > at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path) > at IronRubyConsoleApp.Program.Main(String[] args) in > C:\Projects\ILoveIronRub > y\ILoveIronRuby\IronRubyConsoleApp\Program.cs:line 15 > Press any key to continue . . . > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core@rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core