I've had some requests for a tutorial on installing BlogEngine.NET on Linux (and in particular Ubuntu).

Getting BlogEngine.NET itself to run is the easy part, the hard part is getting the latest release of Mono compiled from source on Ubuntu and getting mod_mono and apache2 configured together.

So to that end I'm starting a series of tutorials, beginning with the installation of Mono 1.2.6 from source on Ubuntu 7.10 (Gutsy Gibbon). These instructions should also work on Ubuntu 6.10/7.04. The next tutorial will be focused on installing BlogEngine.NET itself.

Here's the first tutorial: Installing Mono from source on Ubuntu 7.10 (Gutsy Gibbon)

If you should have any issues with the tutorial, either contact me directly or add a comment on this post, and I'll attempt to guide you through any problems you may have. Any feedback should also help in creating a troubleshooting section for the tutorial to help others out that may have the same issues.

With the Website Template in Visual Studio, all classes in the App_Code directory of your web site is compiled into a temporary assembly of its own when the web app is loaded by IIS. In order to get a handle to the assembly, you can use the following code snippet:

Assembly a = Assembly.Load("__code");

Of course, in Mono it doesn't work that way. To get the temporary compiled assembly you need to use the following:

Assembly a = Assembly.Load("App_Code");

Note that like everything on Linux, the casing matters here!  "app_code" will not work, unless you're running XSP on Windows.

Strangely enough the Mono implementation makes more sense. I couldn't find any information on the interwebs about this issue, so I eventually got it by guessing the correct name!

Not being able to trace through your code while doing a Mono port of an ASP.NET application can seriously hamper productivity. Until the Mono debugger is finally ready for prime time, we'll have to debug the old-school way.

One easy way of getting debug output from a Mono application is to simply use Console.WriteLine. If you're running your ASP.NET application through XSP2, the console output will be visible from the terminal that XSP was run in.

.NET supports using TraceListeners for capturing System.Configuration.Debug output. There is a handy ConsoleTraceListener that will convert all calls to Debug.WriteLine to console calls. This would be fantastic for Mono usage, but alas, Mono does not appear to support TraceListeners at all! My tests have shown that the overridden abstract methods in a TraceLister descendant are never called.

UPDATE: Seems my assumptions about TraceListeners not working in Mono was a bit premature, but not all that far off the mark.

As it turns out, TraceListeners do work, but only when you're running an application that has debugging enabled. This is the expected behaviour, and .NET follows the same guidelines.

However, when running a "Web Site" project (one that hasn't been pre-compiled), Mono still seems to have some issues. If you set the <compilation debug="true"> flag in the Web.config file, the application should be build with debug symbols and all debug output should function as expected. I've confirmed this to work on .NET, but am unable to get this working with XSP2 (Windows or Linux). The debug output does work however if you use a pre-compiled web site (i.e. ASP.NET Web Application in Visual Studio) compiled under the Debug configuration.

The Mono ASP.NET page suggests doing the following:

$ MONO_OPTIONS=--debug xsp2 
Listening on port: 8080 (non-secure) 
Listening on address: 
Root directory: /tmp/us 
Hit Return to stop the server.


This hasn't worked for me however. If anyone knows what I'm doing wrong here, please drop me a line and let me know!

I'm still having problems with mod_mono, and apache. For no apparent reason, mod_mono stops communicating with the mod-mono-server process causing "Service Unavailable" errors to be returned by apache.

In another classic grope-in-the-dark move I've decided to build mod_mono from the daily builds on the anonymous mono SVN server.

I'm not sure that this will resolve the error at all, but for future reference I'm outlining the steps below (official instructions here: http://www.mono-project.com/AnonSVN):

Firstly, you'll need SVN (SubVersion) installed on your linux box. You can do this on Ubuntu with the following command:

apt-get install subversion

The next step is retrieving the sources from the anonymous Mono subversion repository.

svn co svn://anonsvn.mono-project.com/source/trunk/mod_mono 
svn co svn://anonsvn.mono-project.com/source/trunk/xsp

You need to build a new version of XSP too, as mod_mono will fail to run if the XSP and mod_mono versions differ.

Once the sources have downloaded, change into the "xsp" folder and run:

./autogen.sh --prefix=/usr/local; make; make install;

Do the same for the mod_mono folder.

Restart apache:

/etc/init.d/apache2 restart

And you should be done.

I am a software developer / architect currently interested in combining .NET technologies with open-source operating systems. 

I am a member of the open-source BlogEngine.NET development team and focus mainly on ensuring Mono compatibility for the project.



At StayUnlimited Cape Town accommodation we help you choose from and book guest houses, self catering apartments, bed & breakfasts, luxury villas and hotel accommodation.