I am using the following code to execute a Ruby file from C# but it gives me the error: var runtime = IronRuby.Ruby.CreateRuntime(); var engine = runtime.GetEngine("rb"); engine.ExecuteFile("../../HelloWorld.rb"); And here is the error: Unhandled Exception: Microsoft.Scripting.SyntaxErrorException: syntax error, une xpected END, expecting END_OF_FILE at Microsoft.Scripting.ErrorSink.Add(SourceUnit source, String message, Sourc eSpan span, Int32 errorCode, Severity severity) at Microsoft.Scripting.ErrorCounter.Add(SourceUnit source, String message, So urceSpan span, Int32 errorCode, Severity severity) at IronRuby.Compiler.Parser.ReportSyntaxError(String message) at IronRuby.Compiler.Parser.ErrorRecovery() at IronRuby.Compiler.Parser.Parse() at IronRuby.Compiler.Parser.Parse(SourceUnit sourceUnit, RubyCompilerOptions options, ErrorSink errorSink) at IronRuby.Runtime.RubyContext.ParseSourceCode[T](SourceUnit sourceUnit, Rub yCompilerOptions options, ErrorSink errorSink) at IronRuby.Runtime.RubyContext.CompileSourceCode(SourceUnit sourceUnit, Comp ilerOptions options, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Compile(CompilerOptions options, ErrorSink errorSink) And here is the Ruby file: class Person def foo() puts ''hello world'' end end person = Person.new() person.foo() -- Posted via http://www.ruby-forum.com/.
Is it possible that you''ve saved the file as UTF-8 or Unicode? -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam Sent: Wednesday, June 10, 2009 9:55 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] engine.ExecuteFile gives errors I am using the following code to execute a Ruby file from C# but it gives me the error: var runtime = IronRuby.Ruby.CreateRuntime(); var engine = runtime.GetEngine("rb"); engine.ExecuteFile("../../HelloWorld.rb"); And here is the error: Unhandled Exception: Microsoft.Scripting.SyntaxErrorException: syntax error, une xpected END, expecting END_OF_FILE at Microsoft.Scripting.ErrorSink.Add(SourceUnit source, String message, Sourc eSpan span, Int32 errorCode, Severity severity) at Microsoft.Scripting.ErrorCounter.Add(SourceUnit source, String message, So urceSpan span, Int32 errorCode, Severity severity) at IronRuby.Compiler.Parser.ReportSyntaxError(String message) at IronRuby.Compiler.Parser.ErrorRecovery() at IronRuby.Compiler.Parser.Parse() at IronRuby.Compiler.Parser.Parse(SourceUnit sourceUnit, RubyCompilerOptions options, ErrorSink errorSink) at IronRuby.Runtime.RubyContext.ParseSourceCode[T](SourceUnit sourceUnit, Rub yCompilerOptions options, ErrorSink errorSink) at IronRuby.Runtime.RubyContext.CompileSourceCode(SourceUnit sourceUnit, Comp ilerOptions options, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Compile(CompilerOptions options, ErrorSink errorSink) And here is the Ruby file: class Person def foo() puts ''hello world'' end end person = Person.new() person.foo() -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Curt Hagenlocher wrote:> Is it possible that you''ve saved the file as UTF-8 or Unicode?Well I just created a text file with ".rb" extension. -- Posted via http://www.ruby-forum.com/.
That is a problem because visual studio adds UTF-8 encoding to that file. I created one file in notepad and made a template from that file and I use that template to create new ruby files in visual studio. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Fri, Jun 12, 2009 at 7:52 PM, Mohammad Azam <lists at ruby-forum.com> wrote:> Curt Hagenlocher wrote: > > Is it possible that you''ve saved the file as UTF-8 or Unicode? > > Well I just created a text file with ".rb" extension. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090612/3b19ef34/attachment.html>
Here''s the easiest way I know how to check: 1. Open the file in Notepad 2. Choose "File | Save As" 3. Look at the value for "Encoding". If it''s anything other than "ANSI", change the encoding to ANSI, save the file and try again. -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Mohammad Azam Sent: Friday, June 12, 2009 10:52 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] engine.ExecuteFile gives errors Curt Hagenlocher wrote:> Is it possible that you''ve saved the file as UTF-8 or Unicode?Well I just created a text file with ".rb" extension. -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core