[Ironruby-core] Open-Uri Path in App.Config

Jim Deville jdeville at microsoft.com
Mon Mar 1 10:35:34 EST 2010


You need to include the rest of the ironruby search paths. For example. "C:\devtools\ironruby-1.0-rc1\lib\ironruby"

Also, the ir.exe.config from c:\devtools\ironruby-1.0-rc1\bin should be setup exactly like you want. If you provide that to your app it should just work. That's why we install that config file.

JD

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam
Sent: Monday, March 01, 2010 7:22 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Open-Uri Path in App.Config

Here is my implementation:

 static void Main(string[] args)
        {
            var url = "http://www.google.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);

            engine.ExecuteFile("../../screenscraper.rb");
            var obj =
engine.Runtime.Globals.GetVariable("ScreenScraper");

            var screenScraper = engine.Operations.CreateInstance(obj);

            var html = engine.Operations.InvokeMember(screenScraper,
"scrape", url);

            Console.WriteLine(html);

        }


And now it throws the following error:


Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load
-- string
io
   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 25 Press any key to continue . . .





Ivan Porto Carrero wrote:
> 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

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core



More information about the Ironruby-core mailing list