Windows 7 Phone + Ironruby!

In this post I just gonna go through how to get windows 7 phone up and running with ironruby, most are taken from Tomas Matousek but I had to make some customization for it to work!

Step1

Installing the SDK

first of all you have to download the Windows phone 7 developer tools and install those, will take awhile.

Step2

Installing ruby

IronRuby 1.1.2 Installer

and then the binarys from the same URL

step3

Creating the Project

at the moment windows 7 phone need a C# project from were it executes the ruby code, so you have to,

File => New => New Project => Silverlight for Windows phone => Windows Phone Application

remember those binarys from Step 2, now we have to add references to those by,

In solution explorer right click on the reference folder and choose add reference

A dialog window pop up and there you will browse to “IronRuby 1.1.2 Binaries\Windows Phone 7\”
you can add all at once.

Dialog
step4

Creating MainPage.rb

add text file to your project root directory and name it MainPage.rb.
then you have to right click on the MainPage.rb select properties file
set the attribute “Build Action” => “Embedded resource”

step5

configure the enviroment

The constructor of the MainPage.xaml.cs file should look like this ->
contructor_code

On 3rd line from down

Stream codeFile =
execAssembly.GetManifestResourceStream("WindowsPhoneApplication3.MainPage.rb");

replace “WindowsPhoneApplication3″.MainPage.rb to whatever your namespace is for your project.

the reason from step 4 for is to make the GetManifestResourceStream() to return a valid stream, elsewise when we create the Streamreader from the line below it will throw a somethingNullException :)

step 6

Sample ruby code

In MainPage.rb:

include System::Windows::Media
include System::Windows::Controls

# Set the titles
Phone.find_name("ApplicationTitle").text = "Hello World"
Phone.find_name("PageTitle").text = "IronRuby on Windows phone!"

About these ads
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Windows 7 Phone + Ironruby!

  1. Pingback: Developing and IronRuby app for WP7 at iron7

  2. mcandre says:

    Please update this tutorial for Windows Phone 7 Visual Studio 2012. For example, there’s no longer a template for creating Silverlight for Windows Phone projects.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s