RubyCLR – Ruby meets .NET

My day job dictates most of my work be in .NET using C#, for the most part it works well. The usual drawbacks you hear are the costs of implementing a Microsoft solution using Windows 2003 and SQL Server. The platforms are complex but they do work.

In my spare time I have had an interest in learning a new language, which is Ruby. Ruby is a language written by a Japenese developer and has gotten very popular as of late. If you haven’t gotten the chance to look at Ruby it was developed with other languages in mind and trying to better them, SmallTalk and Perl are a couple of those languages. It is well worth a look.

Well it seems a developer named John Lam has created a Ruby to CLR bridge, known as RubyCLR, so developers can create Ruby code under the .NET CLR. It sounds like a match made in heaven and it has been getting more attention as of late.

I downloaded the latest RubyCLR drop from John’s web site and proceeded to install it. Install is a strong word since you simple unzip the contents of the file into a directory. All of the CLR bridge source code is included as well as a bunch of ruby code to handle the Ruby side of things and a bunch of Ruby files that exercises the bridge to the CLR.

The code below is an example from the drop. It brings up a window running in Windows and databinds a drop down list. It’s just works.

require 'winforms'
class MainForm 
  def initialize 
    form      = 
    form.Text = 'Ruby WinForms App' 

names = [] 
    names << 'John' << 'Paul' << 'George' << 'Ringo' 

list = 
    list.data_source = names.make_bindable 

@form = form 

I have installed and tested all of the samples that came with RubyCLR, all but one work and it may be a permission issue on my system I need to work out. John points out his samples were tested in Ruby 1.8.2, but I am running 1.8.4 so it may have something to do with the differing version numbers too.

I plan to write my own .NET apps over the coming weeks using this tool. I report my progress and share the code I create.

Update : 7/30/2007 – the RubyCLR project has moved to RubyForge.  The project can be found at

Technorati Tags : , ,


8 responses to “RubyCLR – Ruby meets .NET

  1. Rob – can you let me know which sample isn’t working? I have other folks who have run things successfully on 1.8.4, but I still haven’t upgraded yet …

  2. John,

    The sample that is not working is the RssReader. I get the following error:

    “C:/Dev/RubyCLR/Src/Ruby/core.rb:244:in `const_missing’: uninitialized constant S
    ystem::Net (NameError)
    from C:/Dev/RubyCLR/Samples/RssReader/rssreader.rb:6”

    All of the other samples work fine.

  3. Hi Rob,
    I am more of a .Net guy than a Ruby, but i’m curious about ruby and mainly how to integrate with .Net.
    While trying the samples, I had the same problem and managed to fix it by doind the following:

    1. Added RubyClr::reference ‘System’ to rssreader.rb
    This should add a reference to System.dll assembly where System.Net namespace can be found.

    2. Mapped paths in offline_links.dat to correct location of rubyclr.

    Hope this is of any help to you…

  4. Pedro,

    I am more of a .NET guy too. My curiosities are the same as yours.

    I did try what you suggested a few days ago and I get a different error.

    Are you using Ruby 1.8.4? I assume your are on .NET 2.0 Framework. I don’t even know if RubyCLR runs on 1.x.

  5. Hi,
    I am also running Ruby 1.8.4 Windows 2K, .NET Framework 2.0.
    I could build project successfully using Visual Studio 2005.
    My question:
    How did you run the above sample program? Did you have to compile the program (with what?)
    Could you guide me thru running above program?

  6. Pingback: Jeremy D. Miller -- The Shade Tree Developer : Using Anonymous Methods with Control.Invoke()

  7. I cannot find the latest IronRuby download anywhere. Any hints? Link?

  8. It was moved to RubyForge, find it here


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s