[Ironruby-core] Open-Uri Path in App.Config
Mohammad Azam
lists at ruby-forum.com
Mon Mar 1 11:38:03 EST 2010
Hi,
>> Probably because your app config is in a different location than ir.exe.
Do you mean the ironruby app config or my application app config? My
application config is in my application directory. The question is that
why it is not reading my application config automatically.
Thanks,
Azam
Jim Deville wrote:
> Probably because your app config is in a different location than ir.exe.
>
> Try this. Replace:
>
> 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);
>
> }
> With:
>
> static void Main(string[] args)
> {
> var url = "http://www.google.com";
> var setup = ScriptRuntimeSetup.ReadConfiguration();
> var scriptRuntime = Ruby.CreateRuntime(setup);
> var engine = Ruby.GetEngine(Runtime);
> //the following line might not be needed in this case
> var context = Ruby.GetExecutionContext(Engine);
>
> 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);
>
> }
--
Posted via http://www.ruby-forum.com/.
More information about the Ironruby-core
mailing list