Working with .NET 3.5 SP1 (Sentinel Client)

January 19, 2009


I recently installed 3.5 SP1 on my development laptop and was merrily coding away for a while before deploying some code to a virtual machine.

Run the code and got this strange error!

Sentinel.v3.5 Client Version

Unable to install or run application.  The application requires that assembly Sentinel.v3.5 Client Version be installed in the Global Assembly Cache (GAC) first.

Cause: Application compiled on 3.5 SP1 then run on machine with only 3.5 installed.

Resolution: Install 3.5 SP1 on the client machine

Thought it was worth posting in case anyone else hits this issue…as I could not find anything on the web about Sentinel!!


Running 10k for charity

January 13, 2009

Some of us at Fitness First are running 10k for the British Heart Foundation.  We are looking to raise £1000 so please give generously and check out my fundraising page.

Thanks for your support!

Protected: HOWTO Rebuild and deploy a new pre-requisite

November 17, 2008

This content is password protected. To view it please enter your password below:

The importance of DLI (Developer Loses Interest)

September 24, 2008

I was developing a wee web-based application the other day, playing around with parsing HTML and developing my love hate relationship with regular expressions.  The same relationship I have with CSS.

Don’t get me wrong I love them! They are both extremely powerful and the deeper I delve the more respect I gain.  However my lack of experience leads to frustration as debugging them is a nightmare.

Stop me if you’ve heard this one.  You get it working…you tinker a little…it breaks!  You cannot step into it or have some compiler tell you where it went wrong it’s just broken till you work methodically back through all the changes you made just to reach square one again!

What is DLI?

This got me thinking.  What I was feeling was very similar to how I feel about some parts of software I have maintained over the years.  I am sure everyone at some point has had some code where debugging an issue was a laborious and tedious task.

Indulge me as I attempt to define this through the following formula 🙂



If the time it takes to reproduce the issue and therefore debug the exact point where it goes wrong is longer than the attention span of the developer, the developer loses interest.

The Cost of DLI

When a developer loses interest they are much more likely to take their eye off the ball.  Best case scenario would be a sloppy check-in which breaks the build!  Worst case is a very bug-centric fix which in fact creates more bugs, which may or may not be found until a much later date (hopefully before it’s released) when the developer has left and it takes someone else ten times the effort to resolve.

Now it is easy to determine the cost of fixing an issue. We can simply use the time spent fixing it along with the developer’s rate.  I am not going to go into the cost of bug fixing here, but if you are interested check out Economics for Developers: Understanding Opportunity Cost by Joseph Finsterwald.

I would say however the cost of DLI is far greater than the time taken to resolve the issue.  I would also say it is even greater than the cost of not fixing the bug at all.  The cost of DLI lies in the time spent fixing waves of bugs specific to one functional area.  Bugs which pop up in a variety of disguises but all smell the same.  Bugs which could have been prevented.  In fact the true cost of DLI may not surface in a project until it is too late and your developer has moved on!

Keeping the cost down

Here are my top 3 tips to ensuring your project does not suffer from DLI:

  1. Test Driven Development – Unit tests can significantly reduce the time taken to reproduce issues.  Less TIME TO REPRODUCE is less likely to lead to DLI!
  2. Keep those creative juices flowing – Don’t let your developer’s stagnate.  Have them work on new areas of functionality.  Increase the DEVELOPER’S ATTENTION SPAN as well as spread knowledge throughout the team.
  3. Pair Programming – Having developers verify each other’s work ensures they care more about the code they produce.  Less likely to let DLI get in the way of a good job.

Of course you could just bin my CV when it comes your way 🙂

NOTE: I am a developer so I am not having a dig.  I have a short attention span and this article is purely based on my personal experience.  For all I know DLI may be solvable with a quick trip to the psychiatrist 🙂

Vista doesn’t trust me!

August 20, 2008

I finally made the leap to Vista, which in truth was more down to my laptop requiring a complete overhaul than my desire to keep up with the Jones’s 😉

After the hours of installs, service packs and updates I was up and running and ready to dev again.

I recently downloaded some code to play around with and on extracting the zip file, opening Visual Studio 2008 and attempting the run the unit tests I got this error:

Test Run deployment issue.  File or location … isn’t trusted

…and all of my unit tests failed to execute.

I searched the web and finally found out that Vista had blocked the zip file I downloaded and subsequently the files extracted from it (strangely though…not all of them).

This issue is easily overcome by clicking the Unblock button under right click -> properties for each offending file.

File Properties Unblock

NOTE: The screenshot here is of my actual solution file which I have not unblocked as it does not seem to cause a problem.

If you have a load of files you need to unblock then look here.


Unit Test Trust Issue on Vista

Tips: Streams, Zones, Vista and Blocked Files in IE

WPF: User settings anyone?

May 11, 2008

I wanted to knock up a simple window to view and edit all the available user settings for an application. I thought this would be a nice article as it shows how to make use of the DataSourceProvider and ObservableCollection.

The first step was to get the settings (SettingsPropertyCollection) into something more manageable.

public class UserSettingsCollection : ObservableCollection<UserSetting> { public UserSettingsCollection(SettingsPropertyCollection settings) : base() { foreach (SettingsProperty prop in settings) { UserSetting setting = new UserSetting(prop.Name, prop.DefaultValue); if (!base.Contains(setting)) { base.Add(setting); } } } }

The UserSetting object starts out very simple (Name/Value) but you will probably want to add some validation and notify the UI when something has changed.

public class UserSetting { public UserSetting(string name, object value) { Name = name; Value = value; } public string Name { get; set; } public object Value { get; set; } }

The only other object I required was some sort of provider to handle the reading and writing of the settings which I called the UserSettingsProvider.

public class UserSettingsProvider : DataSourceProvider { private UserSettingsCollection _settings; protected override void BeginQuery() { _settings = new UserSettingsCollection(Properties.User.Default.Properties); base.OnQueryFinished(_settings); } public void Save() { foreach (UserSetting setting in _settings) { Properties.User.Default.Properties[setting.Name].DefaultValue = setting.Value; } Properties.User.Default.Save(); } }

The XAML is pretty straightforward mainly because it is not my strong point and partly because I just created it manually and therefore didn’t pimp it up in Blend!

<Window.Resources> <ResourceDictionary> <local:UserSettingsProvider x:Key="settingsProvider"/> </ResourceDictionary> </Window.Resources> <Grid> <DockPanel DataContext="{StaticResource settingsProvider}"> <ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding Path=.}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <Label x:Name="NameLabel" Content="{Binding Path=Name}"/> <TextBox x:Name="ValueTextBox" Text="{Binding Path=Value}" Width="200"/> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <Button x:Name="SaveButton" Content="Save" Command="Save" Height="20" Width="50" /> </DockPanel> </Grid>

Only thing worth noting here is that the UserSettingsProvider is bound to the DockPanel (not the ItemsControl). I basically did this so I could pick up the provider from the button’s DataContext when executing the save command like so:

public partial class UserSettings : Window { public UserSettings() { InitializeComponent(); CommandBinding saveCommand = new CommandBinding(); saveCommand.Command = ApplicationCommands.Save; saveCommand.CanExecute += this.CanExecuteSave; saveCommand.Executed += this.Save; this.CommandBindings.Add(saveCommand); } private void Save(object sender, ExecutedRoutedEventArgs e) { Button button = e.OriginalSource as Button; UserSettingsProvider provider = button.DataContext as UserSettingsProvider; if (provider == null) { throw new NullReferenceException("Failed to access the user settings provider."); } provider.Save(); } private void CanExecuteSave(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } }

When it is all put together you get a simple little dialog like this.


I haven’t posted any code files to download for this one because all the code is shown here.

If you did want to take it further and add custom validation or fancy up the UI then feel free to let me know how you get on.


Josh Smith: Binding to the file system

ASP.NET: Users, roles and profiles

May 1, 2008

The have a monster series packed with all the information you need to effectively manage users on your website – ASP.NET 2.0’s Membership, Roles and Profile. The series is based around the SQL Server membership provider but Part 8 specifically shows you how setup an Access-based provider!

If you use MySQL (and I often do) then you can get one of many providers here. I tried this one about a year (or two) ago and seem to remember it working without too much trouble.

ASP.NET: MVC Framework Refresh

April 17, 2008

There has been an unofficial release of the ASP.NET MVC Source Code which is now available on the new ASP.NET CodePlex Project. It now includes unit tests (using Moq – will be blogging on that soon) and some support for testing controllers 🙂

Scott Guthrie has posted everything you need to know about the refresh: ASP.NET MVC Source Refresh Preview. Well worth a read if you are into MVC or MVP!

WPF: Applications for the real world

April 16, 2008

Karl Schifflett has started a monster series on WPF for business applications which is winning awards on CodeProject.

He makes some very strong cases for WPF and how it can meet the demands of real world business applications. This series promises to cover every aspect of WPF and shows how to tackle a business application with WPF effectively. Check out Part One of the series

Also worth checking out this article by Karl: Reasons for choosing WPF over ASP.NET…

WPF: Making good progress

April 15, 2008

Recently I came across a situation where I had a list box of items which I wanted to process on separate threads but report progress to the user. I had never had to do something like this in Win32 let alone WPF so I decided to knock up a little prototype which is the basis for this blog entry.

Download the source code:

The prototype application basically contains a list of video clips which need to be converted. User selects a clip and presses the Convert button which kicks of a new thread to perform the conversion and shows progress through a ProgressBar which is part of the DataTemplate.


First off I defined some simple XAML for the ListBox items:

<Window.Resources> <DataTemplate DataType="{x:Type local:VideoClip}"> <StackPanel x:Name="stack" Background="Gainsboro" Width="200"> <Button x:Name="save" Width="60" Height="20" Click="convert_Click">Convert</Button> <Label Content="{Binding Name}"/> <ProgressBar x:Name="progress" Width="100" Height="15" Maximum="100" Value="{Binding SaveProgress}"/> <Label Content="{Binding Status}"/> </StackPanel> </DataTemplate> </Window.Resources>

Then I wired up the convert_Click event to start a BackgroundWorker thread which runs some code to mimic the conversion. This simply loops for a period of time reporting progress each second or so. The main window hooks into an event on the converter to pick up the progress which can then be set on the ProgressBar.Value.

There were two issues which I came across during this prototype:

1. Accessing the ProgressBar inside a DataTemplate

WPF provides a handy little method called FindName which you can use to find controls within a given ContentPresenter. Not quite as straightforward as the old favourite FindControl 😉

private ProgressBar GetProgressBar(VideoClip clip) { int index = clips.Items.IndexOf(clip); ListBoxItem selectedItem = clips.ItemContainerGenerator.ContainerFromIndex(index) as ListBoxItem; if (selectedItem == null) return null; DataTemplateKey key = new DataTemplateKey(typeof(VideoClip)); DataTemplate template = base.FindResource(key) as DataTemplate; Border border = VisualTreeHelper.GetChild(selectedItem, 0) as Border; ContentPresenter presenter = border.Child as ContentPresenter; ProgressBar progress = template.FindName("progress", presenter) as ProgressBar; return progress; }

This method allows me to take an object (which is the data type for the DataTemplate) from the list and use it to access the ProgressBar control.

2. Update the ProgressBar from a different thread

Converter converter = new Converter(); converter.OnConvertProgress += delegate(object sender1, ConvertEventArgs args) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate { ProgressBar bar = GetProgressBar(args.Clip); if (bar != null) bar.Value = args.Clip.SaveProgress; } , null); };

Using the Dispatcher I get hold of the specific ProgressBar I want to update and simply set the value.