Subscribe: Matt Roberts
Preview: Matt Roberts

Matt Roberts

Rails and .NET

Copyright: Matt Roberts

Hard code

Mon, 30 Jan 2012 10:33:56 GMT

Originally posted on:



That there is a pic




Test post from live writer…

Mon, 30 Jan 2012 08:57:09 GMT

Originally posted on:

Well this is a very dull post, I’m simply trying to post to tumblr from live writer. That is all.


I've moved!

Fri, 01 Apr 2011 08:41:45 GMT

Originally posted on:

Well, it's been a while. I've been here on "geekswithblogs" for a good few years now, and recently not been too active.

So, to spur me on, and inspire me to write more, I've moved to a shinier newer place (no offence GWB). You can find me here:

Adios. (image)

The awesomeness of TeamCity

Wed, 11 Aug 2010 12:25:53 GMT

Originally posted on:

At my current place, we’ve set up TeamCity as our build server. Previously I’ve used and never really questioned it – it works, it does the job, seemed quite nice if a little fiddly to setup.

(If you’re thinking “Hang on, Team City isn't free is it?”  - well there is a free version that is limited to a limited number of projects, configurations and agents – check the site for more details)

I was a bit sceptical about moving to TeamCity because I didn’t want to feel the pain of setting up yet another build/ci server and spending ages trying to get it working with our nant scripts – turns out I was so so wrong to worry. Team city is awesome! Let me talk you through some of the awesomeness…


Setting it up is a breeze



Its seriously easy to set a build configuration using TeamCity. Its all driven through the nice friendly web interface, so a real breeze to setup. Assuming you have an automated build script of some sort set up for your solution (like nant, nant, maven2, msbuild etc) then its really easy to plumb this into Team City. You can set up multiple build agents for your build really easily too.

Fantastic UI

So once you’ve got your build set up, you get all the usual stuff like a build history including things like which check-ins caused the build etc. You can drill into previous builds and see what happened – get the full build log, look at the tests, download the artefacts you defined for the build, all good stuff. You can also manually force a build. If a build fails you can set responsibility for fixing too. All of this is present in most (if not all) CI servers, but its just a lot more polished and feature-rich in Team City. 

Really Awesome Test and Cover Integration

This is what got me really excited (maybe I should be worried about that). You get all sorts of great reports/graphs from Team City that are really useful – like this one:




This shows a history of a swear word test we have, and how long its been taking to run and on what build agent.

If you have test coverage set up (like PartCover) then you can also integrate that and you get some really nice reports showing your coverage by class, methods and LOC – you even get an indicator of what the check-in did to improve (or reduce) that coverage – which is an awesome motivator for adding more tests!


So, all in all, I really like TeamCity, and I’m glad to be using it. If you’re considering getting a CI server set up for your project, or you want to try another flavour of CI server, check it out!


Apps for Macs

Fri, 05 Jun 2009 04:39:43 GMT

Originally posted on: own a mac, I'm a fan of macs, but I'm not a mac-fanboy. I think they're bloody great machines, and that OSX is by far the best OS out there, but I appreciate they're not for everyone. Even osx has (cue dramatic pause) .. flaws. Copy a folder somewhere in OSX, and if the folder already exists on the destination it will prompt you to entirely replace that folder - WOT NO MERGE?! Anyway, apart from that minor niggle, OSX is awesome, especially for web development (in rails). So where am I going with this? Recently a colleague at work has also taken the mac plunge and joined the collective, and so I thought it would be good for me to list the top (free) tools and applications that I couldn't live without on the mac. So, here they are:- 1) Firefox 3 and Safari 4 I can't decide between these, so I use both. Firefox rules for its extensions, while Safari is very fast and slick.   2) Adium Adium is a very nice IM client for the mac. Its light, simple, free of crappy adverts and other such bilge, and best of all, its a green duck. Nuff said. 3) iStat Menus This is a really good system monitoring tool, that sits un-obtrusively in the apple menu, um, thing. Its seriously useful and very configurable, and gives me a reasuring insight into whats happening in the mac 4) Google notifier for mac Its a mail / calendar notifier for the mac. From google. Nice. 5) Quicksilver Ah, the swiss army knife of the mac world. This tool rocks. The blog above is a great write up on Quicksilver, and how to use it. 6) VLC Quicktime player is OK, pretty good for .MOV files, but well not that good for other formats. VLC on the other hand is one of those "just works" apps. it plays videos of most formats. It plays them well, and rarely complains. Nice. 7) Tweetie My mac twitter client of choice. Its a shame is ad-supported, but it really is a nice client, does everything I need, and has a good clean UI. 8) Growl. I can't believe growl isn't actually built into OSX. Its a simple un-obtrusive notification system, that I first heard of when doing automated testing in rails. Turns out a lot of apps support growl notifications. Or maybe growl is just hooking into some central osx notifcation event broker. I dunno, but its very nice, and must be installed. 9) TextMate (or MacVim) Damn it. This one isn't free. But, its very cheap, and for your money you get a very very nice text editor. If you know about rails, you already know about this. If you don't want to pay, I also recommend macvim ( Its a mac port of VIM, done very nicely, and VIM is very nice, as long as you're prepared to master it. And theres some good rails stuff out there for VIM ( 10) Transmission I used this bittorrent client while I was waiting for uTorrent to be available for the mac. I liked it so much I stayed with it. Its simple, effective, pretty much does what it says on the tin. Thats it :) By sheer co-incidence it came to 10 applications. I hope you find this list at least marginally useful, and i [...]

Get Database rollback powers in your NUnit Tests!

Fri, 19 Dec 2008 03:26:05 GMT

Originally posted on: - no credit to me for any of this good stuff. All I'm doing here is posting on how to get database rollback working in your Nunit tests. Roy Osherove created something called XtUnit - "An Unofficial Unit Testing Extensibility Framework - Add new attributes to NUnit or MbUnit easily" - His blog talks you through all the cool stuff that you can do with this framework, like implementing your own attributes to do cool things pre and post method execution. But the thing I wanted more than anything was to add rollback powers to existing NUNit tests, I didn't want to switch to MbUnit to do this, I just wanted to be able to do it with my existing tests. It was pretty simple to get working, but the documentation is a tiny bit in-complete, so this is what you need to do. I'm in Visual Studio 2008, using LLBLGenPro to talk to the database (obviously you don't need to use LLBLGen Pro, but why the hell not!) Download the binaries. You could download the source but you'll need to migrate it to 2008, and I didn't need the src. Reference the binary file that is downloaded in your test project. Make sure that your test fixture class derives from ExtensibleFixture Add the DataRollBack attribute to your test method Done! Here's the code for completion. My example as basically adding a row to a table called "GlobalSearch", in case the LLBLGen stuff looks confusing to you. 1: [TestFixture] 2: public class Class1 : ExtensibleFixture 3: { 4: [Test, DataRollBack] 5: public void TestDataRollBack() 6: { 7: var adapter = new DataAccessAdapter("connection string here", false, CatalogNameUsage.ForceName, ""); 8: // Create a new GlobalSearchEntity, save it, then rollback 9: var g = new GlobalSearchQueueEntity(); 10: g.RecordId = 100; 11: g.ToolCode = "TOOLCODE"; 12: adapter.SaveEntity(g); 13: } 14: } [...]

How to make a "protected" method available for "partial" mocking using RhinoMocks

Tue, 16 Dec 2008 23:00:18 GMT

Originally posted on: are 2 cool things I want to share here... Partial Mocking This is a very cool and useful feature of RhinoMocks, which allows you to test part of a class, but have some of it act normally. Its explained very well here: Making "protected" methods available for mocking. Partial mocks are great, but what do you do when you need to "mock" out a method that isn't visible to your test class - i.e. its private or protected. Well, it turns out you can use a nifty little attribute called InternalsVisibleTo to make any internal methods visible to other assemblies (i.e. your testing assembly). So, in my code, I had a method called GetRecord, which was protected. I changed this to make it protected internal virtual, and added this to my AssemblyInfo.cs file: 1: [assembly: InternalsVisibleTo("NUnitTests")] 2: [assembly: InternalsVisibleTo(RhinoMocks.NormalName)] 3: [assembly: InternalsVisibleTo(RhinoMocks.StrongName)] NUnitTests is the name of my assembly that contains the tests for my project. Once this is done and compiled, intellisense lets me mock that protected method. Just for completeness, here is the code that sets up my partial mock: 1: var mocks = new MockRepository(); 2: var globalSearchServiceBase = mocks.PartialMock(); 3: Expect.Call(globalSearchServiceBase.GetRecord(1)).IgnoreArguments().Return(GetFakeData()); 4: mocks.ReplayAll(); Thats it. Hope that was at least marginally useful to someone :) [...]

CouchDB (with rails)

Sun, 05 Oct 2008 05:27:38 GMT

Originally posted on:

I've been playing with CouchDB a little recently. Its a "schema-free document-oriented database", which sounds pretty weird when all you've ever known is relational databases. At work, we're considering what architecture we want to go with for a new product that needs to be very flexible - the users need to be able to add fields, remove fields, and do all sorts of crazy things with the application.

One of the options we have, is to use something like CouchDB to be able to create an uber-flexible database that can evolve over time, and be very scalable. because our new product will be a SaaS one. Its pretty clear to see why CouchDB fits the bill.

Anyway, its pretty cool, and I wanted to see if I could get started creating a little application in Rails using CouchDB on the back end... It was pretty slow going until I came across this fantastic PeepCode Screencast This screencast goes through the basics of CouchDB, and then goes on to build a nifty notes-esque web application using a CouchDB gem called CouchRest.

Its a quality peepcode, and the CouchRest gem looks like its really going to help me :)

It'll be interesting to see what kind of take up CouchDB or other schema-free cloud computing databases get in the .NET world, I don't see much happening out there at the moment.

Anyway, watch out for my killer CouchDB-based rails application, coming soon (yeah right!) (image)

Get your (old) COM-based or "ASP.NET with Interop" web app working in Windows Server 2003 R2 64 Bit !

Fri, 11 Apr 2008 20:27:23 GMT

Originally posted on:

AKA: "Why am I getting 'ActiveX can't create component' when I try to access my COM DLL's"
AKA: "Why am I getting 'Service Unavailable' when I've set IIS to run in 32 bit compatibility mode.
AKA "Why do I get 404 errors when I browse to my ASPX pages"

Man that's a long title :)

So, I recently had to spend some time looking into getting my companies web application working in 64 Bit Windows (2003 R2 to be exact). I eventually got this working, but found the information scattered and incomplete on the interweb, so this little guide should see you through. I hope someone out there finds it useful.

Starting Point.

You have windows 2003 R2 64 bit SP1. You have the 64bit version of the .NET framework (V2 or higher) installed. No other changes have been made to IIS - it seems to run just fine for serving .NET and HTML. You install your web application that includes COM, try to run it, and BANG...

Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object

The cause? Its because those COM objects are 32 bit components, and by default IIS won't work with 32 components. You need to tell IIS to run in 32 bit compatibility mode (WOW64). To do this, you need to configure IIS to run in 32 bit compatibility mode, as explained by this link.

But wait! Its not quite that easy! If you do this, then you're telling IIS to run in 32 bit mode, but then you've already got the 64 bit ASP.NET DLL's registered with IIS, so the first time you hit your app, you'll probably see a big fat "Service Unavailable" Error message. If you look in the event log, you'll see your application pools are crashing with this error:

A process serving application pool 'DefaultAppPool' reported a failure.
The process id was '4156'. The data field contains the error number.

So, you need to register the 32 bit ASP.NET DLL's with IIS. But wait! You can't do that before you un-register the existing 64 bit ones.

Enough waffling. Here's the step-by-step :-

  1. Un-register the 64 bit ASP.NET DLL's. In a command prompt, navigate to C:\Windows\Framework64\v2.0.50727\ and from there run "aspnet_regiis -u"
  2. Set IIS to work in 32 bit compatibility (WOW64) mode:
    cscript c:\inetpub\AdminScripts\adsutil.vbs set w3svc/AppPools/Enable32BitAppOnWin64 1
  3. Register the 32-Bit ASP.NET DLL's. Navigate to C:\Windows\Framework\v2.0.50727\ and from there run "aspnet_regiis -i"
  4. Finally, in IIS, Navigate to "Web Service Extensions", and make sure that ASP.NET is "allowed".

You're done!


Categories in Rails

Sat, 15 Dec 2007 00:00:46 GMT

Originally posted on:

Rails makes such a nice change from coding in .NET. I mean, I do like .NET and C#, but sometimes its very bloated and can be quite cumbersome to do things.

Rails, on the other hand, isn't big. Or cumbersome. In fact, its downright lean and to-the-point, unlike my blog posts (what there are of them!).

Anyway, today we're talking category trees, surely one of the most exciting concepts that there is to talk about. One thing that made me smile recently was the need to list all the categories that a company was tagged to. So, this happens with code that looks like this :-

<%for cat in @Categories %>
    <%= + "
" %>
<% end %>

.. Where @Categories is a collection of categories from the controller, and is generated like this:

@Categories = Company.find(params["id"]).Category.find(:all)

So, this noddy code just lists all cats that the company was tagged to. After deploying this, I was asked to change it so that the full hierarchy of categories was displayed. So instead of "Cat 1", the user wants to see "Root -> Services -> Cat 1". Hmmm, I thought, perhaps I need to write a little recursive method to go and get the parent nodes of each selected category... Turns out that because I was using acts_as_tree in the model (google it!), I was able to solve this with a really simple bit of code added to the category model :-

    def fullcategoryname
        self.ancestors().each() { |parent| fullname += + " / " }
        fullname +=

Thats nice! :) Gotta like Ruby.


Test Post from Windows Live Writer

Tue, 09 Oct 2007 15:28:53 GMT

Originally posted on:

Testing from Windows live writer :)


Ruby ruby ruby ruby! (on rails)

Thu, 19 Apr 2007 02:58:10 GMT

Originally posted on:

I recently decided to play around a bit with Ruby on Rails, its had so much hype so I thought it would be interesting to see how it fares up against ASP.NET programming!

Anyway, I'm only just starting out, but first impressions are very very good indeed! Ruby seems to be a very intuitive language, although I wouldn't say I preferred it to C#. However, the rails framework that deals with all the agile web framework side of things seems awesome!! Really easy to use and get a reasonably complex web site up and running.

I'm going to waffle on a bit more about this in the future, but in the meantime if you're interested in giving it a go on a windows box, its ridiculously easy - you don't even have to "install" any software!! Just do this:

1) Download "InstantRails".
From the website: Instant Rails is a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all pre-configured and ready to run. No installer, you simply drop it into the directory of your choice and run it. It does not modify your system environment.
2) Get a "development environment setup"
If you're used to being spoilt/abused by Visual Studio and want something all nice and integrated, then you need to get RadRails. RadRails is a free plugin for the excellent-if-sometimes-a-little-too-slow-for-me Eclipse devenv from Sun. It needs the java runtime to work. Anyway, get it from
Alternatively, use VIM with ruby plugins, or something else :)
3) Follow some tutorials.
Start here....
Then here.... (image)

You know its going to be a long day when...

Thu, 04 Jan 2007 20:23:00 GMT

Originally posted on:

Installing the Visual Studio 2005 Service Pack and you get this.....



Happy New Year!

Wed, 03 Jan 2007 03:31:00 GMT

Originally posted on:

Well, its another new year (did I mention that?) I'm going to make a big attempt to update my blog more often than I did towards the end of last year, that was pitiful to be honest.

So, what better way to start the new year than installing some free software to make your development/computing life that bit easier.... Here's my top 5 list of "Stuff I always install when I rebuild my machine":

  1. Notepad2. Its my fave notepad replacement, with all the usual syntax highlighting and cool features. Check it out:
  2. TaskSwitchXP. Its a fantastic Alt-Tab replacement with loads of cool features.
  3. Firefox with extensions. The best browser gets even better when you start playing with extensions. There's so many good ones, but AdBlock and AllInOneSideBar always make my list. For web developers, check out FireBug (
  4. Omea Reader. Its a free RSS reader and much more. I only use it for RSS feeds, and I really like it for that. I used to use SharpReader until I paid attention to the amount of memory it was consuming!
  5. Foxit Reader. For the love of God don't use that horrible piece of bloated tat known as Adobe Reader. There is a better way, and its here:

I could go on for another 20 entries here, but these are probably my top ones... Oh, and "Query Express" ( oh and LLBLGen, but thats not free! (image)

"Touching Base"

Wed, 25 Oct 2006 23:13:00 GMT

Originally posted on:

I'm just "touching base" with my blog, which basically means if you convert the management speak crap to normal, that I have nothing in particular to say of interest to the world in general.

What I will say is that I'm happily on Firefox 2 now. It seems to boot a lot faster in windows, and I like the subtle changes to the UI (improved tabs etc). I also think that the improved RSS support is pretty cool, those Live Bookmarks are damn useful!

I'm just waiting for the next release of Ubuntu (6.10) to be released, then I'll boot back into Linux and get FF2 installed in that too.

Cool Javascript/CSS Sidebar reference

Almost forgot to mention it, check this cool AJAX powered sidebar refernence for CSS/JScript (and MySQL/PHP too if you're that way inclined)