Tim Hastings - NonHostile (because there's no need)

Weblog and collection of geeky articles.

  Home :: Who? :: Contact :: Links :: Subscribe subscribe
Privacy Risk With Internet ExplorerMore Industrial Revelations with Mark Williams - God Be Praised!!Now Witness the Power of This Fully Armed and Operational Debian NSLU2

Mono AMI for Amazon EC2

For anyone interested in experimenting with Mono on Amazon EC2 I have created a publicly available image which you can instantiate and play with. It can be used for both ASP.Net applications and console applications. The image does not have a GUI so this is not an appropriate platform to test applications with a GUI.

Update: a Mono 2.2 AMI is available

The EC2 AMI is:

Getting Started
It is beyond the scope of this post to cover the basics of using Amazon EC2, there are already great tutorials on how to do this. Once your instance is up and running, you can take your browser to the public DNS name to play with the ASP.Net XSP sample pages. Most of the samples are implemented in C#. There is some chatter in the forums saying that some of the ASP.Net samples are a bit broken, most work, please feel free to fix any bugs and contribute back :-)

If you want to host you own web pages, you will need to modify the Apache config file and either modify the served directory (at the bottom of /etc/httpd/conf/httpd.conf) or alternatively, add new virtual directories or virtual hosts as explained in mod_mono's documentation

I would also strongly advise any .Net developers interested in Linux to knock up a quick "Hello World" console application in Visual Studio and the copy it across to Mono. You do not have to recompile for Mono, it just works™, the Mono boffins have created a binary compatible version of the CLR and you app doesn't know the different (unless it starts to get get nosey). The only difference is that .Net executables have to be launched with the Mono command line tool, like this:
mono hello-world.exe
This instance was made from:
  • Amazon’s Fedora 8 image (ami-f51aff9c v1.06)
  • Apache 2.2.6 installed via yum
  • Mono 1.9.1 binary installation
  • mod_mono 1.9 compiled and installed from source
  • Apache and mod_mono are configured to serve the XSP 'test' files from the web site's root in /etc/httpd/conf/httpd.conf (at the bottom)
As part of my What’s on my iPod? Facebook application I have been using Amazon EC2 to host the PHP front-end application and Mono to run the backend data processor which is a console application implemented in VB.Net (written in Visual Studio 2005).

On occasion, I have tried to get ASP.Net working, but never quite got it right, and never really had to. But, this evening I have had a break-through, so I thought I would share my progress with anyone interested.

Color Blue is not a valid color (I disagree)
I had made many failed attempts to get ASP.Net working on Apache with mod_mono and mod-mono-server but usually came unstuck with obscure errors when executing some pages. Depending on the test page, it would report: "Color Green is not a valid color" or "Input string was not in the correct format" errors thrown from System.Drawing.WebColorConverter

After much searching and experimenting, the problem was pinpointed to System.Drawing's dependency on libgdiplus.so, when this library is installed (via yum) it would install the library as "libgdiplus.so.0.0.0", and a symbolic link to it called "libgdiplus.so.0", but not create the "libgdiplus.so" symbolic link required by System.Drawing - which causes this fault. If you are experiencing this problem, make sure that libgdiplus.so exists in /usr/lib, if it does not, you can create a symbolic link to it with:
ln -s /usr/lib/libgdiplus.so.0 /usr/lib/libgdiplus.so
Extra credits go to wangli, Sebastien Pouliot-2, Max Karavaev and Abe Gillespie for figuring this out

  • Mono: The Mono homestead
  • mod_mono: Documentation on configuring mod_mono
  • Amazon EC2: The mother ship
  • Elasticfox: a Firefox Extension for Amazon EC2
  • WinSCP and PuTTY: The essential SSH tools for Windows
  • Twitter: My twitter link if you want to keep in touch

bookmark this on del.icio.us

© 2008 Copyright Tim Hastings
p.s. please do not draw attention to the irony that this blog is implemented in Classic ASP – move along, there’s nothing to see here.

801 comments, Development, Tuesday, July 1, 2008 02:25

Timeline Navigation for Development posts
MySQL Replication between Amazon EC2 Instances - How To Setup Replication in The Cloud (made 13 weeks later)
MonoAmi: Hosting ASP.Net, C# and VB.Net with Mono on Linux in The Amazon EC2 Cloud (this post, made Tuesday, July 1, 2008 02:25)
Software Development 101 - How to fix a bug (made 86 weeks earlier)


Post a Comment
Name:  Home page and email address are optional.
  Email addresses will not be displayed or spammed!
Remember these details
Home Page:
Comments cannot contain HTML, URLs will be formatted into hyperlinks.
I reserve the right to remove any comments for any reason.