Restoring PCs using Windows Home Server

Over the last week I’ve had an unlucky streak with hardware on my home computers. Firstly my sons aging P3 tower had a hard disk failure. It wasn’t catastrophic but it was preventing new data from being written to the drive. So I copied everything off onto the Home Server’s shared folders.

Then I grabbed an old 6.4 Gb drive (yes they used to make them that small) and installed a vanilla copy of Windows XP. It took about 10 hours and 10 reboots to get this all the way up to Windows XP SP2 with IE 7 and all the latest patches. It also meant the drive had about 400 Mb free.

At this point I figure I’ll copy across a couple of files from the Home Server only to find its not responding. Turns out that the CPU (an old P4) has fried itself. Bugger.

So a trip to the local computer shop and I’ve got an el’ cheapo Core2Duo (4500), Asus motherboard (P5B-VM-SE) and 1 Gb of generic RAM. I rip out the old MB and replace with new components hoping and boot the machine. First thing I find is that it doesn’t even recognize the CPU. A quick download and flash of the latest motherboard BIOS fixes that, but the machine still won’t boot into Windows – reboots as soon as it hits the windows loader.

So I spend a few hours re-installing Windows Home Server. This is actually a lot less painful than Windows XP was – it has a neat feature that allows you to re-install the system partition without effecting any of the data backups or shares – very nice. During the installation though I can’t help noticing an odd “pfft” sound that comes from my son’s P3 which is supposed to be turned off. Turns out that the power supply (cranky old 230 W) has chosen this moment to commit suicide.

Next day – off to the shop again to get a new power supply. I opt for the slightly more expensive Thermaltake PSU with a 12cm fan. Theory being larger the fan slower the required rotation and therefore less noise. I was thinking I’d swap with the Home Server since that’s going to be running 24/7. However, surprisingly the new PSU was louder than the existing PSU in the Home Server that had two 8cm fans – weird.

So now my sons P3 machine has a whopping 550W PSU – major overkill – most of the connectors aren’t even compatible with the motherboard.

But now the cool bit.

  • I boot up the P3 connect to the Home Server and do a full system backup. Easy – does this very quickly across my 1Gb network (all my machines have 1Gb LAN) and connect to a 1Gb switch with the exception of the Home Theatre PC which is currently wireless only.
  • Next I power down the P3 – rip out the 6.4 Gb disk with the recently installed Windows XP and replace with a spare 30 Gb disk from my main workstation (I figure it can do with the 4 remaining newer drives).
  • Then I reboot the P3 using the Windows Home Server Restore CD. This takes a while to load – but when its done it then allows me to follow the prompts and restore the previous system image onto the new drive. It doesn’t care that the drive is a different size – as long as its >6 Gb. It even lets me go in and create partitions on the new drive before I do the restore.

Very nice! Well done Windows Home Server team!!

Off Track

Ok – I’ve managed to get a little side-tracked – there are just so many things rummaging around in my head at the moment.

This one popped into (virtual) reality the other day – a WPF based application notification area (status panel). The idea is that the panel interacts with a validation engine which governs all validation on a given page. It would also be related to a WPF equivalent of ErrorProvider. The WinForms ErrorProvider was kinda cool for doing simple demos but in real apps I always thought it was a bit of a joke. I’m aiming here to produce “notifications” that have associated metadata – primary text, secondary text (the long version), actions (e.g. intellisense options, corrective measures), locators (e.g. click to focus on the bad control) etc.

Based on previous experience most of this is really easy – its the rules validation engine that gets tricky – especially when table validation is required (e.g. grids).

 StatusPanel v0.1

I Command Thee – Exception?

Ok – so I’m reading through WPF Unleashed and I finish reading the chapter on the various deployment types which also covers the inbuilt page navigation framework. Now this is something that I’m very interested in having attempted the feat myself a few times. So I decide its time to stop reading, roll up the sleeves and give it a try.

To start with I try something like this:

The startup XAML defines we’re using a NavigationWindow with the startup page being HomePage.xaml.

<NavigationWindow x:Class="WpfParameterPassing.Window1"
    Title="Window1" Height="300" Width="300"

The HomePage contains a Button and a TextBox. The idea is that the Button triggers the navigation passing the content of the TextBox to the called page.

<Page x:Class=”WpfParameterPassing.HomePage”
        <Button Content=”Make Selection” Click =”Button_Click”/>
        <TextBox x:Name=”selectionTextBox”/>

The page to call is defined as a PageFunction which means it allows a value to be returned. The type of this return value is defined by the x:TypeArguments attribute, in this case a string. The called form just has an Ok and Cancel button, together with a TextBox that is populated with the input parameter and which is used to populate the return value.

<PageFunction x:Class="WpfParameterPassing.SelectFunction"
            <Label Content="Choice to return:"/>
            <TextBox x:Name="choice" HorizontalAlignment="Stretch" Width="150"/>
            <Button x:Name="okButton" IsDefault ="True" Content="_OK" 
="Right" Click
="Button_Click" /> <Button x:Name="cancelButton" IsCancel="True" Content="_Cancel"
="Right" Click
="cancelButton_Click" /> </WrapPanel> </StackPanel> </PageFunction>

A little bit of code behind for the HomePage is used to trigger the navigation and to subscribe to the Return event so we can update the TextBox with the value returned from the called page.

    public partial class HomePage : Page
public HomePage()
private void Button_Click(object sender, RoutedEventArgs e)
SelectFunction nextPage = new SelectFunction(selectionTextBox.Text);
nextPage.Return += new ReturnEventHandler<string>(nextPage_Return);
private void nextPage_Return(object sender, ReturnEventArgs<string> e)
if (!string.IsNullOrEmpty(e.Result))
selectionTextBox.Text = e.Result;

Some code behind on the PageFunction derived class is used to wire up the Ok and Cancel buttons. The constructor overload is then used to allow the input parameters to be passed. I like the idea of using constructors to pass the parameters – neat. [Its a shame parameterized constructors can’t be used to initialize objects in XAML – but that’s a whole other story.]

    public partial class SelectFunction : PageFunction<string>
public SelectFunction()
public SelectFunction(string previousSelection) : this()
choice.Text = previousSelection;
private void Button_Click(object sender, RoutedEventArgs e)
OnReturn(new ReturnEventArgs<string>(choice.Text));
private void cancelButton_Click(object sender, RoutedEventArgs e)
OnReturn(new ReturnEventArgs<string>());

So – put all this together and it works as expected. Enter a value on the first page (HomePage) – click the button and the value is transferred to the second page (SelectFunction) where it can be modified and returned via the return result.

The next step is to get rid of all that code behind that binds HomePage to SelectFunction. What better way to do this than with a Command? This is where things began to get fuzzy. If I want to create my own command what should it derive from? After a few false starts attempting to derive from RoutedCommand etc. I decide not to derive from anything and just implement ICommand myself.

    public class SelectCommand : ICommand, INotifyPropertyChanged
private string _selection;
public SelectCommand()
//Text = "Select Choice";
public Page CallingPage { get; set; }
public string Selection
{ return _selection; }
_selection = value;
private void OnPropertyChanged(string p)
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(p));

        #region ICommand Members
public bool CanExecute(object parameter)
return true;
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
if (CallingPage == null)
CallingPage = (Page) parameter;
if (CallingPage == null)
throw new InvalidOperationException(
"CallingPage cannot be null when invoking the Execute method."); SelectFunction nextPage = new SelectFunction(Selection); nextPage.Return += new ReturnEventHandler<string>(nextPage_Return); CallingPage.NavigationService.Navigate(nextPage); }
#endregion private void nextPage_Return(object sender, ReturnEventArgs<string> e) { if (!string.IsNullOrEmpty(e.Result)) Selection = e.Result; } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion }

Get rid of all the code behind in HomePage and redefine the Button and TextBox to instantiate a new command and a bit of binding to glue it together.

       <Button Content=”Make Selection” CommandParameter=”{Binding ElementName=_this}”>
               <local:SelectCommand x:Name=”selectCommand”/>
       <TextBox x:Name=”selectionTextBox” Text=”{Binding ElementName=selectCommand, Path=Selection}”/>

Now that’s much better. My button is set to execute a command when its activated (Clicked) and the command controls the page navigation and parameter passing for me. We get the result back into the page simply by binding our output field (in this case selectionTextBox) to the Selection property of the command (essentially the output parameter).

But does it work… well no. It generates this little beauty:

WPF Exception

Hmm… so is this a bug – or have I somehow hooked into some interop? If I remove the event handler subscription to the Return event everything works fine – except of course I don’t get my value .

I even tried Dispatching back to the UI thread in case it was a weird threading related issue – no luck. Interestingly when I first attempted to create my command by inheriting from RoutedCommand the button was disabled. This was despite the fact that my CanExecute method is hard-coded to return true. Its at this point I think I need to go back to the books – I’m obviously missing something.


And the answer is given here.

To work around the limitation I need to make the callback for the return an instance method of the calling form. Hmm… easy enough passing as a callback delegate in C# but how to declare that in XAML? Not too sure about the merits of this limitation – means putting code in the HomePage code behind again.

        public void Returned(object sender, ReturnEventArgs<string> e)
if (!string.IsNullOrEmpty(e.Result))
selectionTextBox.Text = e.Result;

Oh – and a bit of reading into RoutedUICommand makes things clearer as to why inheriting from it got me nowhere Maybe it can help me with the problem above though?

Windows Home Server RTM

Just setup my Windows Home Server machine to the RTM version (from RC). Performed a manual backup using a single drive (320Gb) which does an amazing job of backing up my main workstation and the home theatre PC [this isn’t a full backup given the workstation alone has over a terabyte of disk – but its most of the important stuff]. However, I then included the second drive into the storage “array” and the backups started failing again. This was the same problem I had with the RC – basically the server machine just reboots halfway through a backup. It seems like a hardware issue given how sudden the reboot is (there is nothing untoward reported in any of the event logs) – but as to which device is failing…

The most obvious candidate would be the second hard drive – a 400Gb Seagate drive. Thing is I’ve run all of Seagate’s own diagnostics over this drive (SeaTools) and it comes up fine every time. Maybe its the SATA controller – but that’s an on-board device which also is operating the primary drive. Maybe its the Intel gigabit on-board LAN controller – but why does it only fail when the second drive is operational. The Seagate drive is marginally faster than the Western Digital – but both drives are less than 6 months old. The S.M.A.R.T. diagnostics for both drives also look pretty normal – with both showing near-perfect health.

Another annoying problem is that I can’t seem to install the Windows Home Server Connector software on my sons PC. It was all working fine under the RC but for some reason refuses to un-install correctly and hence can’t install the update. Frustrating – I was about to resort to some sysinternals tools to track exactly where it was getting stuck – but figured its probably time to just rebuild the machine anyway given its a very old box whose OS has probably hasn’t been re-installed for 6 years or so. Was thinking of upgrading it from XP SP2 to Vista but my 4 ½ year old son has some nostalgic feelings towards XP and isn’t ready for the leap (stumble?) to Vista.

As for the Windows Home Server box itself… dunno – I checked out some motherboard and PSU pricing tonight. Its currently running a crusty old P4 2.8GHz and given its going to be running 24 hours a day I figured I might opt for a more energy efficient choice with a silent PSU to boot. The home theatre PC is silent from any distance greater than 30cm and uses a CoreDuo mobile chip. Seems like a Home Server box should probably be running the same sort of hardware… which leads me to wonder why I need both a Home Server and Home Theatre PC – both of which run 24/7. Oh well – I think its a common sentiment that hopefully the Home Server team will address in the next version.


Slowly but steadily working my way through the WPF book. There are some huge similarities between a lot of what’s in WPF and that I’ve been working on (in my day job) over the last 3 years. This isn’t surprising given that we based a lot of our work on some early XAML samples from Microsoft (and others). I’m already imagining how it would be possible to build an infrastructure framework over the top of WPF to more easily create business applications. So should I dig into Acropolis or just go ahead and build my own?

Extension Methods

This is one feature in C# 3.0 that I’ve been really looking forward to for a long time.

It gives us the ability to extend classes that we didn’t author and can’t inherit. One of the key benefits I see in this is the ability to extend primitive .NET classes such as String, Int32 etc. These classes can’t be inherited so there hasn’t previously been a neat way of extending them.

The following example adds a rather simplistic method to the System.Int32 type – IsPrime which simply returns true or false depending upon whether the integer is a prime number. [Ok – I know the method is half done and performs poorly – its meant to explain extension methods not prime number evaluation algorithms].

    public static class ExtensionTest
public static bool IsPrime(this int value)
for (int denominator = 2; denominator <= value / 2; denominator++)
if (value % denominator == 0)
return false;
return true;
    public class Test
public void TestMethod()
for (int i = 0; i < 100; i++)
if (i.IsPrime())
System.Diagnostics.Debug.Write(i + ", ");

What I really love about the .NET implementation is the way in which extension methods are understood by the IDE intellisense and how you bring the extension methods into scope by importing (using) the namespace. This means the you only see the relevant methods based on the current namespace scope.

The intellisense displays a little arrow against the standard method icon to indicate that the method in question has been extended by a static extension method. Very cool.

 Intellisense drop down showing IsPrime extension method

Little to Report

I haven’t made any progress for the last week on my WPF attempt at PhotoPlay for a bunch of reasons relating to work and home commitments. I’m pretty disappointed about this – I had hoped to have got further. The good news is that I received an e-mail on Monday from indicating that my book has been shipped and I should expect it by the end of the week.

I must admit I almost resorted to Amazon when purchasing this book – but then at the last minute I figured there must be a local alternative with quicker shipping. The local alternative was fractionally cheaper although I believe they still import the book from their overseas distributors, so I doubt the delivery would have been much different. I’m glad I bothered to look around though because I’m an anti-fan of Amazon – I know the rest of the world disagrees but I just find the entire Amazon web experience to be dismal. Their search never seems to work – even when you know they have the book, and their ordering/check-out process is frustrating.

Hmm… Ok – I had a bad day at work today – vent over…

PhotoPlay v0.1 – WPF

Err… well it sure don’t do much yet but if you just can’t get enough of spinning a photo around then here is the ClickOnce install.

So far I’ve tackled some very simple DependencyPropertys, binding, control templating and event triggers. As I always find when learning something like this from scratch – simple things can take a long time. The only reference that I’ve used so far aside from the MSDN help is an excellent intro to writing WPF custom controls by Mark Miller in a recent episode of dnrTV.

WPF Book

I’ve just ordered Windows Presentation Foundation (WPF) Unleashed by Adam Nathan – my first technical reference purchase in around 15 years. Normally I find most technical books to be average to lousy and I’ve never read one cover to cover. The pace is often too slow, they never go deep enough unless they are a pure reference book in which case they never have enough realistic examples to make it all work. [Interesting to note that this book is only 40% of the cost of the other book – not taking into consideration the 15 years of inflation. Publishing must have gotten a whole lot cheaper!]

From what I’ve heard and read recently I think the true technical reference book is dead – online help and search are just so much more affordable, portable and accurate. I still think there is a need for the more technology overview type book (else why would I have bought this one ).

Windows Presentation Foundation Unleashed (WPF) (Unleashed)

So why did I choose this book over others by authors such as Charles Petzold, Chris Anderson etc.

  1. Has by far the best cover :-p
  2. Is printed in full colour. I know a lot of people will think that’s a lame reason but I’ll stand by the fact that the best technical books I’ve kept from my Uni days are those that are well published. That means good typography, layout, diagrams etc. Of course most of those use colour to because let’s face it – now that the cost appears negligible (this book didn’t cost me any more than the others would) why wouldn’t you? Unless of course you’re the kinda developer that switches all the syntax formatting in Visual Studio to black and white
  3. Ok – so I remember reading quite a few blog articles talking about the differences between the WPF books mentioned and I felt that I liked the sound of this one more than the others.

I probably won’t get my hands on this till around 7th September – I wonder how much I will have figured out by then. Oh well – I guess its tax deductible anyway…

PhotoPlay – WPF – It Lives!

Ok – so tonight I finally had the courage to install Visual Studio 2008 Beta 2 on my relatively new and until now pristinely clean development machine. The install process was the standard tried and true Visual Studio install engine and completed slowly but without any problems (only one reboot required).

So I immediately fire up Visual Studio 2008 – choose the C# preferences which gives me all the wrong keyboard shortcuts (I can never remember which is which). Create a new WPF application with solution folder. The add a new WPF user control library to the project. So far so good.

Renaming UserControl1 to PhotoPage and changing the namespaces turns out to be as bad as renaming in Visual Studio 2005. Have to rename the file, class, namespace and XAML all independently.

First impressions:

  • XAML editor hasn’t immediately crashed – way more stable than previous builds!
  • XAML editor is almost real-time and is only a little slow to load – way faster than previous builds!
  • WPF has changed everything – even finding equivalent of BackColor to create a coloured background takes time. At least Fill is spelt correctly :-p
  • XAML Intellisense is great for auto-complete – but where are the help tooltips?
  • Hmm… appears Shapes have a Fill and controls have a Background.
  • Don’t click on the helpful sounding message telling you the assembly has changed and XAML needs to be refreshed. Seems to crash Visual Studio every time

My first attempt at a XAML only approach:

PhotoClass : UserControl

<UserControl x:Class="Spencen.Windows.Controls.Photo"
        <Border Name="OuterFrame" CornerRadius="5">
                <LinearGradientBrush Opacity="0.8">
                    <GradientStop Color="Azure" Offset="0.0"/>
                    <GradientStop Color="CadetBlue" Offset="1.0"/>
            <Border Name="InnerFrame" Background ="White" BorderBrush="Black" 
="6,6,6,6"> <Image Name="image2" Margin="1, 1, 1, 1"> <Image.Source>
F:\Pictures\Camera Photos\2007\Mount Hotham\DSC06994.JPG
> </Image> </Border> </Border> </StackPanel> </UserControl>

PhotoPlayWindow : Window

<Window x:Class="Spencen.Windows.PhotoPlayWindow"
    Title="PhotoPlayWPF" Height="428" Width="619">
        <Slider Name="scaleSlider" Height="21" Width="100" 
Minimum="0.1" Maximum="5.0" Value="1.0"/> <Slider Name="angleSlider" Height ="21" Width="100"
="-180.0" Maximum="180.0" Value="0.0"/> <p:Photo Height="230" Width="300" Name="testPhoto"> <p:Photo.LayoutTransform> <TransformGroup> <ScaleTransform ScaleX="{Binding ElementName=scaleSlider, Path=Value}"
="{Binding ElementName=scaleSlider, Path=Value}"/> <RotateTransform Angle="{Binding ElementName=angleSlider, Path=Value}"
="150" CenterY="150"/> </TransformGroup> </p:Photo.LayoutTransform> </p:Photo> </StackPanel> </Window>