Hire me at Go Tripod.

HotSwap for Monorail – In Action

September 23rd 2007, 12:08 pm in .NET, Agile Development, C#, Castle, Monorail, Screencasts, Windsor.

Ayende quickly posted something called HotSwap, which is a little snippet of code which uses a FileWatcher, Windsor, and on-the-fly code recompilation to increase your productivity. With ASP.NET, building your code changes causes an appdomain restart, and you will typically have to wait a few seconds for the appdomain to come back up before the browser will display your changes. This basically means that when working with ASP.NET, there are no quick code changes – you always have that four second wait till you see the effects.

HotSwap resolves this by building your code for you when it detects a change. Using Windsor it can swap out the old assembly containing your code and replace it with a new dynamically created assembly containing your new code – all automatically. The key advantage of this is that it’s all done in-memory, and none of the DLL files in the bin directory change. This means that you won’t trigger an appdomain restart and your changes can be seen almost instantly!

I was really impressed and excited by this approach so I did a very quick screencast on the topic. I was using the Castle RC3 MSI, and created a project with Windsor integration enabled. This code only works for your controllers at the moment, but a lot of the time that’ll be where you need this kind of productivity boost.

Ayende – cheers for this, and I’m sorry if I pronounced your name wrong as I’ve only seen it written down!

UPDATE: I’ve uploaded the HotswapTest Project from the screencast. You’ll probably need the Castle RC3 MSI installed to build it.

Responses to “HotSwap for Monorail – In Action”

Comments are closed.

  1. [...] hearing Colin pronounce it) posted on an idea he has – MonoRail HotSwap and Colin Ramsay did a screencast of MonoRail HotSwap.  I know that the AppDomain having to reset because a code change occurred can be annoying [...]

    MonoRail HotSwap - J.D. Meridth
  2. Colin,

    Cool stuff. You have to do more of these screencasts. They are very helpful. Instead of going and looking at the code real quick. I can watch you set it up and then go look at the code if I want. It’s great!

    As always, keep up the good work man!

    Sean

    Sean Chambers
  3. [...] post di Ayende Introducing MonoRail.HotSwap e lo screencast fatto da Colin Ramsay dal suo post http://colinramsay.co.uk/2007/09/23/hotswap-for-monorail-in-action/. Posted: Sep 24 2007, 09:52 AM by andrea.balducci | with no comments Filed under: library, [...]

    Introducing MonoRail.HotSwap - moleskine di un programmatore
  4. Will this work using webforms?

    Harry M
  5. Harry M:

    The approach uses the Windsor container, and could be adapted to work with anything you put in the container. In this case it happens to be controllers but if you have a decent separation of your layers in WinForms then I think you could do something similar, yes.

    colinramsay
  6. Nice screencast Colin. Can you post de entire source code (I have some experience with MR but not with Windsor)

    Thanks

    Jose