I am trying to get a Ruby file to run through C#. I was reading through "Ruby Unleashed" (book), and it appears to be easy. However, I keep getting an error on a very simple test. The text of my programs are: C#: using System; using Microsoft.Scripting.Hosting; using IronRuby; class Run_Ruby { static void Main() { ScriptEngine engine = IronRuby.Ruby.CreateEngine(); engine.ExecuteFile("C:/Test_Files/hello.rb"); } } ------------- hello.rb: puts ''hello'' When I run the program I get: "MissingMethodException was unhandled" "undefined method `???puts'' for main:Object" I am a novice to C#, but this should be hard. What am I doing wrong? Attachments: http://www.ruby-forum.com/attachment/5280/C_toRuby.jpg -- Posted via http://www.ruby-forum.com/.
What version of IronRuby do you use? The file has UTF8 BOM at the beginning and IronRuby 1.0 doesn''t support that (MRI 1.8.6 doesn''t either). IronRuby 1.1.1 should work fine. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Tuesday, November 02, 2010 11:07 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Running IronRuby script from C# I am trying to get a Ruby file to run through C#. I was reading through "Ruby Unleashed" (book), and it appears to be easy. However, I keep getting an error on a very simple test. The text of my programs are: C#: using System; using Microsoft.Scripting.Hosting; using IronRuby; class Run_Ruby { static void Main() { ScriptEngine engine = IronRuby.Ruby.CreateEngine(); engine.ExecuteFile("C:/Test_Files/hello.rb"); } } ------------- hello.rb: puts ''hello'' When I run the program I get: "MissingMethodException was unhandled" "undefined method `???puts'' for main:Object" I am a novice to C#, but this should be hard. What am I doing wrong? Attachments: http://www.ruby-forum.com/attachment/5280/C_toRuby.jpg -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
before i think about it too much, it seems you have some unicodish chars in the file? On Tue, Nov 2, 2010 at 8:07 PM, Timothy Barnes <lists at ruby-forum.com> wrote:> I am trying to get a Ruby file to run through C#. I was reading through > "Ruby Unleashed" (book), and it appears to be easy. However, I keep > getting an error on a very simple test. The text of my programs are: > > C#: > using System; > using Microsoft.Scripting.Hosting; > using IronRuby; > > class Run_Ruby > { > static void Main() > { > ScriptEngine engine = IronRuby.Ruby.CreateEngine(); > engine.ExecuteFile("C:/Test_Files/hello.rb"); > } > } > ------------- > hello.rb: > puts ''hello'' > > When I run the program I get: > "MissingMethodException was unhandled" > "undefined method `???puts'' for main:Object" > > I am a novice to C#, but this should be hard. What am I doing wrong? > > Attachments: > http://www.ruby-forum.com/attachment/5280/C_toRuby.jpg > > > -- > 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/20101102/257f1e89/attachment.html>
confirmed. you probably created the file inside VS, or other UTF happy editor. if you insist you might want to try the encoding pragma, but i''m not sure of its support # coding: utf-8 puts ''hello'' On Tue, Nov 2, 2010 at 9:41 PM, Dotan N. <dipidi at gmail.com> wrote:> before i think about it too much, it seems you have some unicodish chars in > the file? > > > On Tue, Nov 2, 2010 at 8:07 PM, Timothy Barnes <lists at ruby-forum.com>wrote: > >> I am trying to get a Ruby file to run through C#. I was reading through >> "Ruby Unleashed" (book), and it appears to be easy. However, I keep >> getting an error on a very simple test. The text of my programs are: >> >> C#: >> using System; >> using Microsoft.Scripting.Hosting; >> using IronRuby; >> >> class Run_Ruby >> { >> static void Main() >> { >> ScriptEngine engine = IronRuby.Ruby.CreateEngine(); >> engine.ExecuteFile("C:/Test_Files/hello.rb"); >> } >> } >> ------------- >> hello.rb: >> puts ''hello'' >> >> When I run the program I get: >> "MissingMethodException was unhandled" >> "undefined method `???puts'' for main:Object" >> >> I am a novice to C#, but this should be hard. What am I doing wrong? >> >> Attachments: >> http://www.ruby-forum.com/attachment/5280/C_toRuby.jpg >> >> >> -- >> 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/20101102/941132d9/attachment.html>
Thanks for the replies. I recreated hello.rb in Scite and the program worked. I have read about UTF8 encoding and ruby, but had not ran into it before, and I didn''t not know what the symbols in front of the hello.rb text meant (see VS error message). So thanks for the help. Tomas: I was using IronRuby 1.0.0.0 but had just downloaded IronRuby 1.1.1. However, I originally created the file in SharpDevelop and have been creating IronRuby programs in SharpDevelop with no issue (running in SD Debug), until I tried to call this ruby file from C#. So I still don''t quite understand why ruby works one way and not the other, but that seems to be a SharpDevelop issue/setting. I am pretty sure SharpDevelop is running IronRuby 1.0.0.0. After I couldn''t get it to work I tried it again in Visual Studio which I assume also called IronRuby 1.0.0.0. since I still had that version installed and my files associated with that version. Last, Now that IronRuby supports the UTF8 encoding, should my files be encoded that way? Or now does it just not matter which encoding I use? and does C# have to be encoded UTF8? -- Posted via http://www.ruby-forum.com/.
this is not an ''issue'' with either editors. it is simply a matter of encoding. As i previously noted, you''ve created the file in visual studio, which adds: http://en.wikipedia.org/wiki/Byte_order_mark please find the time to read this http://www.joelonsoftware.com/articles/Unicode.html On Wed, Nov 3, 2010 at 3:19 PM, Timothy Barnes <lists at ruby-forum.com> wrote:> Thanks for the replies. > > I recreated hello.rb in Scite and the program worked. I have read about > UTF8 encoding and ruby, but had not ran into it before, and I didn''t not > know what the symbols in front of the hello.rb text meant (see VS error > message). So thanks for the help. > > Tomas: I was using IronRuby 1.0.0.0 but had just downloaded IronRuby > 1.1.1. However, I originally created the file in SharpDevelop and have > been creating IronRuby programs in SharpDevelop with no issue (running > in SD Debug), until I tried to call this ruby file from C#. So I still >don''t quite understand why ruby works one way and not the other, but> that seems to be a SharpDevelop issue/setting. I am pretty sure > SharpDevelop is running IronRuby 1.0.0.0. After I couldn''t get it to > work I tried it again in Visual Studio which I > assume also called IronRuby 1.0.0.0. since I still had that version > installed and my files associated with that version. > > Last, Now that IronRuby supports the UTF8 encoding, should my files be > encoded that way? Or now does it just not matter which encoding I use? > and does C# have to be encoded UTF8? > > -- > 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/20101103/f36ae356/attachment.html>
Dotan, Thanks for the links. I have been looking for a place to explain encoding well for awhile. I am a self-trained programmer and sometimes it is hard to find good info to increase my knowledge base. Thanks for the help. -- Posted via http://www.ruby-forum.com/.
Files don''t need to be encoded in UTF8, you can chose any encoding supported on your system. IronRuby 1.1.1 supports BOMs and also Ruby specific #encoding directives. I would suggest always using UTF8. Personally I consider any non-Unicode based encoding obsolete and frankly don''t understand why Ruby went the way they did with all that complexity around encodings. It just makes it slower and cumbersome to use. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 03, 2010 6:19 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Thanks for the replies. I recreated hello.rb in Scite and the program worked. I have read about UTF8 encoding and ruby, but had not ran into it before, and I didn''t not know what the symbols in front of the hello.rb text meant (see VS error message). So thanks for the help. Tomas: I was using IronRuby 1.0.0.0 but had just downloaded IronRuby 1.1.1. However, I originally created the file in SharpDevelop and have been creating IronRuby programs in SharpDevelop with no issue (running in SD Debug), until I tried to call this ruby file from C#. So I still don''t quite understand why ruby works one way and not the other, but that seems to be a SharpDevelop issue/setting. I am pretty sure SharpDevelop is running IronRuby 1.0.0.0. After I couldn''t get it to work I tried it again in Visual Studio which I assume also called IronRuby 1.0.0.0. since I still had that version installed and my files associated with that version. Last, Now that IronRuby supports the UTF8 encoding, should my files be encoded that way? Or now does it just not matter which encoding I use? and does C# have to be encoded UTF8? -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Tomas, I appreciate the suggestion. The reason I was trying to do this was to create and .exe file that I can distribute to other co-workers without them having to understand what ruby is. The only other answer I can''t find through internet searches is whether on not I can suppress the console window while running a window application through IronRuby. (similar to the using a .rbw file) It appears that this is not possible. Is that correct? Timothy -- Posted via http://www.ruby-forum.com/.
it is possible to embed without a console window :) On Wed, Nov 3, 2010 at 7:59 PM, Timothy Barnes <lists at ruby-forum.com> wrote:> Tomas, > > I appreciate the suggestion. > > The reason I was trying to do this was to create and .exe file that I > can distribute to other co-workers without them having to understand > what ruby is. The only other answer I can''t find through internet > searches is whether on not I can suppress the console window while > running a window application through IronRuby. (similar to the using a > .rbw file) > > It appears that this is not possible. Is that correct? > > Timothy > > -- > 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/20101103/8c3b551a/attachment.html>
Not today, but it would be easy to implement. I can do it over the weekend if you need it. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 03, 2010 10:59 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Tomas, I appreciate the suggestion. The reason I was trying to do this was to create and .exe file that I can distribute to other co-workers without them having to understand what ruby is. The only other answer I can''t find through internet searches is whether on not I can suppress the console window while running a window application through IronRuby. (similar to the using a .rbw file) It appears that this is not possible. Is that correct? Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
I mean you can indeed write a Windows app in C# or VB that hosts IronRuby and that doesn''t need the console window (you can redirect standard output to a stream if you would like to display it in some window). The thing that''s missing from IronRuby is irw.exe file that would do that for you (we have a similar one for Python). Tomas -----Original Message----- From: Tomas Matousek Sent: Wednesday, November 03, 2010 1:06 PM To: ironruby-core at rubyforge.org Subject: RE: [Ironruby-core] Running IronRuby script from C# Not today, but it would be easy to implement. I can do it over the weekend if you need it. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 03, 2010 10:59 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Tomas, I appreciate the suggestion. The reason I was trying to do this was to create and .exe file that I can distribute to other co-workers without them having to understand what ruby is. The only other answer I can''t find through internet searches is whether on not I can suppress the console window while running a window application through IronRuby. (similar to the using a .rbw file) It appears that this is not possible. Is that correct? Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Tomas, Do you mean create a irw.exe file? That would be great. I don''t want to take up too much of your time, but it would be a great help. Again, thanks for the replies. Timothy -- Posted via http://www.ruby-forum.com/.
Yes, should be easy. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 03, 2010 2:37 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Tomas, Do you mean create a irw.exe file? That would be great. I don''t want to take up too much of your time, but it would be a great help. Again, thanks for the replies. Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Tomas, Where should I look for this file when you are finished? Timothy -- Posted via http://www.ruby-forum.com/.
It''s already there - build Solutions\Ruby.sln from GIT repo (https://github.com/ironruby/ironruby/archives/master): msbuild Solutions.Ruby.sln /p:Configuration=Release This produces binaries to bin\Release directory. You''ll need to take all IronRuby binaries (not just irw.exe). Of if you''d rather make an installer (IronRuby.msi) go to Msi directory and run msbuild Installer.proj /p:Configuration=Release This produces the .msi also into bin\Release. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Monday, November 08, 2010 7:52 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Tomas, Where should I look for this file when you are finished? Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Tomas, I built the binaries using msbuild (command line). I then copy all of the resulting files into my bin folder and now even using ir.exe results in an error message: unknown: no such file to load -- gem_prelude.rb (LoadError) Can you tell me what I have done wrong? Also, when I tried to build the .msi installer a .msi file doesn''t show up in the bin Release Folder. I am unsure if there is something wrong or it is my incompetence. Timothy -- Posted via http://www.ruby-forum.com/.
There are some issues with how library load paths are set up today (gem_prelude load error), I''m working on a fix. I might finish it this weekend. Did you pass /p:Configuration=Release to msbuild when building the installer? If not look at bin\Debug folder :) Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 10, 2010 11:57 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# Tomas, I built the binaries using msbuild (command line). I then copy all of the resulting files into my bin folder and now even using ir.exe results in an error message: unknown: no such file to load -- gem_prelude.rb (LoadError) Can you tell me what I have done wrong? Also, when I tried to build the .msi installer a .msi file doesn''t show up in the bin Release Folder. I am unsure if there is something wrong or it is my incompetence. Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
I did pass /p:Configuration=Release to msbuild and checked the debug folder. I did get 4 errors which might have been the cause. They were 20-30 lines long so I didn''t type them out here. Would it help for me to post them? Also, am I correct in the fact that you have to build the solution Ruby.sln before you can build the installer.proj? Timothy -- Posted via http://www.ruby-forum.com/.
No, you don''t need to build anything before you build the installer. What are the errors? Do you have VS SDK 2010 installed? You need to have that so that the VS integration builds. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Wednesday, November 10, 2010 2:02 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# I did pass /p:Configuration=Release to msbuild and checked the debug folder. I did get 4 errors which might have been the cause. They were 20-30 lines long so I didn''t type them out here. Would it help for me to post them? Also, am I correct in the fact that you have to build the solution Ruby.sln before you can build the installer.proj? Timothy -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
I did not have VS SDK 2010, which I now have installed and the build is still failing. I have attached a copy of some of the error text from the unsuccessful build, if you want to look. More info: Only have Visual C# Express 2010 installed - Not sure if this is affecting the build. Using command prompt to build. Timothy Attachments: http://www.ruby-forum.com/attachment/5342/msbuild_errors.txt -- Posted via http://www.ruby-forum.com/.
Can you attach the entire output? Did you synced to the latest version of the repo? TOmas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Thursday, November 11, 2010 11:05 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# I did not have VS SDK 2010, which I now have installed and the build is still failing. I have attached a copy of some of the error text from the unsuccessful build, if you want to look. More info: Only have Visual C# Express 2010 installed - Not sure if this is affecting the build. Using command prompt to build. Timothy Attachments: http://www.ruby-forum.com/attachment/5342/msbuild_errors.txt -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
This is all the text left in the command prompt box. Unless there is a way to record what happens (or different software), I don''t know how to capture all of the text for the build. Timothy Attachments: http://www.ruby-forum.com/attachment/5343/msbuild_errors.txt -- Posted via http://www.ruby-forum.com/.
msbuild Installer.proj /p:Configuration=Release > output.log Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Thursday, November 11, 2010 12:26 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# This is all the text left in the command prompt box. Unless there is a way to record what happens (or different software), I don''t know how to capture all of the text for the build. Timothy Attachments: http://www.ruby-forum.com/attachment/5343/msbuild_errors.txt -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
I have attached the output.log file. Timothy Attachments: http://www.ruby-forum.com/attachment/5352/output.log -- Posted via http://www.ruby-forum.com/.
Can you pull the latest source from gthub and try to build again? I fixed some issues, so it should work now. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Timothy Barnes Sent: Friday, November 12, 2010 10:44 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Running IronRuby script from C# I have attached the output.log file. Timothy Attachments: http://www.ruby-forum.com/attachment/5352/output.log -- Posted via http://www.ruby-forum.com/. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core