hello_world.rb only contains: puts "Hello, World!!!"<br><br>hth<br>Ivan<br><br><div class="gmail_quote">On Jan 28, 2008 12:23 PM, Ivan Porto Carrero <<a href="mailto:ivan@flanders.co.nz">ivan@flanders.co.nz</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Greg, <br><br>This is what i used at some point, that should still work atm.<br><br>class Program<br>
{<br> static void Main(string[] args)<br> {<br> //TODO: review this when the hosting api changes.<br>
IScriptEnvironment runtime = ScriptEnvironment.GetEnvironment();<br><br> Console.WriteLine("Executing from file:");<br> runtime.ExecuteFile("..\\..\\hello_world.rb");<div class="Ih2E3d">
<br>
<br> IScriptEngine engine = IronRuby.GetEngine(runtime);<br></div> IScriptScope scope = engine.CreateScope();<br><br> List<string> strings = new List<string>();<br> strings.Add("Hello, ");<br>
strings.Add("World!!!");<br> IronRuby.GetExecutionContext(runtime).GlobalVariables[SymbolTable.StringToId("strings")] = strings;<br><br> SourceUnit script = engine.CreateScriptSourceFromString(<br>
@"<br>puts ""Hello World! There are #{$strings.count.to_s} strings:""<br>$strings.each_with_index { |s,i| puts ""#{i}: #{s}"" }<br>");<br><br> Console.WriteLine("Executing from string:");<br>
engine.Execute(scope, script);<div><div></div><div class="Wj3C7c"><br> }<br> }<br><br><br><br><div class="gmail_quote">On Jan 28, 2008 12:16 PM, Greg Akins <<a href="mailto:angrygreg@gmail.com" target="_blank">angrygreg@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">OK, so I couldn't get some of the simple examples of using RubyEngine<br>to start calling Ruby from C#...<br>
<br>So I spent a bit reading through the mailing list archives (realizing<br>while doing that, that I'd asked a frequently asked question).<br><br>Now, I hope I'm not asking another stupid question.<br><br>I found another post (<br>
<a href="http://rubyforge.org/pipermail/ironruby-core/2008-January/000616.html" target="_blank">http://rubyforge.org/pipermail/ironruby-core/2008-January/000616.html</a><br>) that suggests a method of running Ruby.<br><br>
However, I get an error on this line<br><br> IScriptEngine engine = IronRuby.GetEngine(runtime);<br><br>Which shows this stack trace<br><br> at System.RuntimeMethodHandle._InvokeConstructor(Object[] args,<br>
SignatureStruct& signature, IntPtr declaringType)<br> at System.RuntimeMethodHandle.InvokeConstructor(Object[] args,<br>SignatureStruct signature, RuntimeTypeHandle declaringType)<br> at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags<br>
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)<br> at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,<br>Binder binder, Object[] args, CultureInfo culture, Object[]<br>activationAttributes)<br>
at System.Activator.CreateInstance(Type type, BindingFlags<br>bindingAttr, Binder binder, Object[] args, CultureInfo culture,<br>Object[] activationAttributes)<br> at System.Activator.CreateInstance(Type type, Object[] args)<br>
at Microsoft.Scripting.Utils.ReflectionUtils.CreateInstance[T](Type<br>actualType, Object[] args) in<br>c:\Libraries\IronRuby\trunk\src\microsoft.scripting\Utils\ReflectionUtils.cs:line<br>127<br><br>--<br>Greg Akins<br>
Software Development Manager<br>SSI Services<br><br><a href="http://kc.vanadium.com" target="_blank">http://kc.vanadium.com</a><br><a href="http://www.pghcodingdojo.org" target="_blank">http://www.pghcodingdojo.org</a><br>
<a href="http://www.insomnia-consulting.org/monologue" target="_blank">http://www.insomnia-consulting.org/monologue</a><br>_______________________________________________<br>Ironruby-core mailing list<br><a href="mailto:Ironruby-core@rubyforge.org" target="_blank">Ironruby-core@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/ironruby-core" target="_blank">http://rubyforge.org/mailman/listinfo/ironruby-core</a><br></blockquote></div><br>
</div></div></blockquote></div><br>