Tuesday, December 19, 2006

Debug viewer saves the day!

Not that you should be putting debug builds into a production environment, but when you do how do you view the debug output? You can’t run using the VS debugger so what do you do?

Well, I found this tool today, and it's the answer to your (and my) prayers!


Naturally, it's a Sysinternals product (OK - they're owned Microsoft now) - go get it!

Monday, December 18, 2006

ASP.Net AJAX on an existing site (redux)

How-To's are almost always useful - and this one from Jay Kimble is no exception.

In it, he explains in detail How To: Enable Microsoft ASP.NET Ajax Extension RC1 (and Dec. 2006 CTP) on an existing site
- something I've blogged on before, but it's nice to have a second piece for reference.

Thursday, November 23, 2006

Roland Weigelt's GhostDoc - Just use it!

I've been trying this VS2005 add-in for the last couple of days, and it's safe to say that it ROCKS!

From the site:
GhostDoc is a free add-in for Visual Studio that automatically generates XML
documentation comments. Either by using existing documentation inherited
from base classes or implemented interfaces, or by deducing comments from
name and type of e.g. methods, properties or parameters.
In use, it's great for going back over hurriedly written code to write the in-code comments we're all SUPPOSED to write as we go - took me about a minute to completely document a complex ASP.Net server control, and I had to adjust the comments of only 3 methods.

Get Roland Weigelt's GhostDoc - you know it makes sense!

Wednesday, November 22, 2006

Quick Tip: Checking for a reference type null in C#

How do you test for a null reference type in C#?

You'd think that it'd be easy to check for a null, just use some code like this:

MyType thing = null;
if ( thing == null)
// do something

But what if you need to test for a null within an overloaded == operator?!
You can't use the simple code above, as this would cause a stack overflow.

The trick is in casting the entity to a different type and so that the compiler uses the == for that alternate type. I wrap this test into a static IsNull() method on the class.

public static bool IsNull(MyType thing)
object testThing = thing as object;

// uses the == operator from object, NOT MyType
return (testThing == null);

So now I can safely test for equality, including correctly testing for nulls like this

public static bool operator == (MyType thing1, MyType thing2)
// two nulls => equal
if (IsNull(thing1) && IsNull(thing2))
return true;

// one null => not equal
if (IsNull(thing1) || IsNull(thing2))
return false;

// do the REAL equality test here

Simple when you know how! And absolutely essential when you're implementing IEquatable.

Friday, November 17, 2006

Sometimes the simplest things are most effective

I've been playing with Joel Fjordén's Code Style Enforcer
recently, and reckon it's one of the smallest, simplest and most useful VS IDE plugins around.

It's basically a DXCore plugin that redlines (draws a hand-drawn red line underneath) any c# code that doesn't meet the basic style guidelines from the iDesign C# coding standard.

I have to admit that finding the right properties page for the plugin to let me customise the rules too a while (find it by selecting DevExpress -> Options -> Code Standard -> Name Rules from the VS menu), but now it's great - I get instant feedback when I'm not meeting the basic coding standards.

Find it here...
And go use it!

Tuesday, October 10, 2006

JSON - The bottom sponge in the cake

You can hardly have missed the explosion of "Web 2.0" sites, and the excitement around AJAX and in the .Net community, ATLAS.

However, when using the wonderfully simple UpdatePanel from ATLAS, it's actually the markup that's being sent over the wire as part of an asynchronous call.

It's been at the periphery of my consiousness for a while, but I came across a link to Jayrock today that makes me mindfull of optimising the out-of-band communications by using something a bit more clever than markup deltas.

Jayrock is a framework for JSON and JSON-RPC for .NET - it makes exposing services to JSON-RPC as easy as creating an HTTPHandler.

And it's open source too!

Strong names and Assembly loading

The MSDN Flash newsletter that hit my inbox today contained a number of interesting things, but what most piqued my interest was a link to a very good article on VSJ.

Titled Strength in naming, it provides a very good overview of how strong names are used to sign assemblies, which in turn allows them to be inserted into the GAC.

In it, Ian Stevenson provides a very nice little flow-chart of the assembly loading process - the article is worth a read just for that.

Thursday, September 28, 2006

Using Generic types in DataContracts

In a short post titled "DataContract names for Generic Types
", Sajay Antony provides a wonderfully useful snippet of code to allow you to use generics in your WCF data contracts. Short, sweet and useful.

Friday, September 22, 2006

Debugger bites man

In this blog entry, Anson Horton holds his hands up as being (at least partially) responsible for a feature of the VS debugger that is at once invaluable and incredibly frustrating - Function Evaluation.

He also describes the problem very clearly, which is an effective reminder about not writing code that can self-substantiate unless that is essential.

Of course, when you're writing complex OO architectures, self-substantiation is a real temptation - but with this clear reminder, it should be easier to spot those occasions when self-substantiating objects have masked the fault condition.

Required reading.

Saturday, September 16, 2006

Plip does it again!

Wednesday saw another well-organised, interesting and informative VBUG event - this one a "SPECIAL NON-MEMBER EVENT" entitled "Flirting with AJAX with Gary Rowntree".

The location was once again QA Training in Stockport - a great little venue apart from the very hard seats!

Gary did a great intro to ATLAS - Microsoft's AJAX technology libraries - easing those who'd not played with it before through the concepts and basic techniques whilst fielding deep technical questions from others in the audience. Finishing the session off by writing a simple chat application from scratch was a definite crowd pleaser.

It was nice to be able to chat to other developers and guage their experiences with the technology, and I think that the informality of these events is a definite positive.

Kudos to Phil Winstanley (plip) for organising another event - the prize draw was a nice surprise, even if I did win the CodeZone hat. Still, my 20 month old, Daniel, thinks it's great!

Now when's the next one?

Footnote: This was written using Windows Live Writer running on Vista RC1. I'm such a beta-whore! :-)

Wednesday, September 13, 2006

Change is a-comin'

I've been watching the progress of Mono for a while now, but until quite recently it's not been feature-rich enough to support porting my ASP.Net projects.

In this blog entry, Miguel de Icaza highlights how SplendidCRM was ported in a couple of hours thanks to a VMWare image of a fully-configured Mono development environment.

This is something I'm going to HAVE to install and play with - being able to deploy ASP.Net web sites on Linux, or even better virtualised Linux instances is going to be a very cost-effective and scalable solution - particularly if you add Amazon's Elastic Compute Cloud for dynamic scalability.

Tuesday, September 12, 2006

ATLAS going mainstream (and other entertainment)

In this blog entry, Scott Guthrie gives us the low-down on Microsoft's plans for actually releasing ATLAS as a supported product. This can only be good news, as it means that the technology will now get 10 years of support from Microsoft. The only down side is that to accelerate the release schedule, what's currently available as two products (ATLAS and the ATLAS Control Toolkit) will get busted into 3 or more - the balancing act being that of having a slightly harder maintenance process versus much better support.

On a related note, I'm looking forward to the VBUG Special Non-Member Event at QA Training in Stockport tomorrow evening . Titled "Flirting with AJAX with Gary Rowntree", it promises to demonstrate how to develop an IM application using ATLAS.

I wonder whether anyone's done any worked examples of integrating intranet-based applications with Sharepoint, Communications Server et al for presence management and embedded communications - seems to me that this is exactly what "joined up" applications are about. If you're going to be at the event, give me a wave.

Friday, September 01, 2006

Visual Studio .NET 2005 Keyboard Shortcuts

In his blog, "mapo" (a Microsoft consultant) links to handy Visual Studio .NET 2005 Keyboard Shortcuts as well as to a macro to generate the printable crib-sheet.

This has been around for a while, but kudos to Jeff Atwood of Coding Horror for this handy helper. His "recommended reading" is excellent too - its contents will be gracing my Amazon wish-list shortly, and should do for any serious / professional developer. Although, as one commenter points out, it doesn't include the "Gang of Four" book, nor my recommendation, Howard & LeBlanc's Writing Secure Code.

Thursday, August 31, 2006

Making editing TFS Build Types easy

Via a fairly convoluted route, I came across this add-in for Visual Studio 2005 today.

The Attrice Corporation Team Build Sidekick is a freeware (yes, really!) source-available add-in that lets you check out and edit a Team Build project as easily as you might any other source file.

No longer do we have to go and find the file in Source Control Explorer! Huzzah!

TFS and remote working

I've been using TFS at work for a few months now, and am pretty impressed with it.

My only real problem is with taking work home - at the moment it's a matter of copying via a memory stick, but that causes problems as VS relies on the readonly file state to determine whether a file has been changed.

This article by Martin Woodward details what will probably be the way forward for me - a VPN to home and a local TFS proxy - letting me keep my workstation and laptop in sync at home.

I'll probably have to use a virtual server instance tho', rather than having another server in the house.

For working disconnected on the laptop, Dave Glover gives the solution to preventing your copy of VS from connecting to TFS in this blog article. Unsurprisingly, it's a simple registry hack.

Deep Team Server joy will be mine! ;-)

Wednesday, June 21, 2006

The Power of Predicates

I ran up against a problem I'd not encountered before today - how to use the Find method on a generic List. The MSDN documentation is less than enlightening, but I found an excellent article entitled "Using generics to manage a collection of objects" byAmirthalingam Prasanna on simple-talk.com.

Amirthalingam covers the subject in detail, but I thought I'd share my reference implementation (and put it up somewhere that I can find it when I forget how to do this!). Purple elipses ( ... ) indicate where the finished code continues.

We'll implement a simple C# console application to start with to act as the framework for our reference implementation.
using System;
using System.Collections.Generic;
using System.Text;

namespace List_Find_Predicate_Test
class Program
static void Main(string[] args)
Next, let's define a "complex" class against a List of which we will search - we'll do this as a private inner class within our framework:
class Program
private enum Gender

private class Criteria
public string Field;
public Type DataType;

public Criteria(string theField, Type theDataType)
this.Field = theField;
this.DataType = theDataType;
You'll notice I've spiced things up with a custom enumeration used within the Criteria class. Next, let's add some code to the Main method to build us a list of criteria objects:
static void Main(string[] args)
List<Criteria> critList = new List<Criteria>();
critList.Add(new Criteria("Name", typeof(System.String)));
critList.Add(new Criteria("Age", typeof(System.Int16)));
critList.Add(new Criteria("Gender", typeof(Gender)));

Console.WriteLine("List has {0} entries...", critList.Count);

// TODO: Search the list
Simple enough so far. The complexity happens in providing a mechanism to let the List.Find method operate - this is where Predicate classes come in. Predicates are analagous to Delegates - they effectively implement a call-back to a method that performs the comparison, and it is this call-back that the Find method uses to find matching elements in the List.

Let's add a quick search of the List, and get the type assigned to the "Name" criteria:
static void Main(string[] args)
// Search the list
Criteria crit = FindCriteriaByName(critList, "Name");
Console.WriteLine("Name criteria has type {0}", crit.DataType.Name);

// TODO: Search without having to use a helper method

// TODO: Implement FindCriteriaByName
OK - that was easy enough - just your common-or-garden-variety top-down programming so far. But now we get to the meat of the issue - the implementation of the FindCriteriaByName method - and this is where Predicates are used.

The key to Predicates is that they reference a class - in this case a class that is dedicated to filtering a List. We'll implement this as another private class within the program framework. This filter class is as simple as they come, taking a string parameter for its constructor, and exposing just one method FilterByField.
class Program
private class CriteriaFieldFilter
private string criteriaField;

public CriteriaFieldFilter(string fieldName)
criteriaField = fieldName;

public bool FilterByField(Criteria crit)
return (crit.Field == criteriaField);
You'll notice that the critical FilterByField method accepts a Criteria object as its parameter - when we call this class through a Predicate, this is the method that will be used to perform the filtering. So we can now finally implement the filter method:
class Program
// Implement FindCriteriaByName
private static Criteria FindCriteriaByName(List<Criteria> theList, string theName)
CriteriaFieldFilter searchFilter = new CriteriaFieldFilter(theName);
Predicate<Criteria> searchPredicate = new Predicate<Criteria>(searchFilter.FilterByField);
Criteria crit = theList.Find(searchPredicate);
return crit;
So our filtermethod starts by instantiating an instance of our filter class tailored with the field name passed in the theName parameter. The Predicate is then created against a pointer to the FilterByField method of that instance, and in turn that Predicate is used with the List.Find method to return the matching entry.

But is there a more compact way rather than having to implement the helper method at all? Of course there is! We just compact the code into an in-line function, thus:
static void Main(string[] args)
// Search without having to use a helper method
crit = critList.Find(new Predicate<Criteria>((new CriteriaFieldFilter("Gender")).FilterByField));
Console.WriteLine("Gender criteria has type {0}", crit.DataType.Name);
Rather harder on the eye, but more compact. I'd imagine that something could be done with Anonymous classes/methods to simplify this further, but that's a topic of research for another time.

Phew! A complex topic for just performing a Find in a List, but it does allow us to write any kind of matching algorithm we like working against just a single T instance and they use that matching algorithm to work with an entire List - that's the power of Predicates.

Thursday, June 15, 2006

Visual Studio Managed Code Analysis (FxCop) : FAQ: Why does FxCop warn against catch(Exception)? [Nick Guerrera]

In his recent posting titled "FAQ: Why does FxCop warn against catch(Exception)?":, Nick Guerrera does a great job of explaining best practice in exception handling.

I’ve heard a lot of arguments against DoNotCatchGeneralExceptionTypes, but they generally boil down to one or both of the following:
  • “If I call an API which doesn’t document which exceptions it can throw, then I have no choice but to catch all possible exceptions!”

  • “My application needs to be robust; it can’t crash just because of an exception that I forgot to handle!”
Well worth reading and thinking about how you code your exception handling routines - I know for one I use catch (Exception e) w-a-y too much!

Thursday, June 01, 2006

SOA, Autonomy and Caching

In the latest posting in his blog, Clemens Vasters gives an excellent reminder about what SOA really means for a developer or architect, and of some of its history.

But it's the pragmatism that Service Autonomy doesn't really matter under the hood because behind the service boundary is a private domain and "none of your business" to the outside world.

Finally, he makes some good points about caching, and particularly about passing forward cache validity information along with the data so that a client of a service can make an intelligent caching decision.

All well worth keeping in mind when, as I, you're building a large distributed system - find it here.

Jay Kimble -- The Dev Theologian : How to Add Atlas to an existing site (For Brendan)

Getting started with a new technology is one thing, but retro-fitting it onto an existing project is quite another.

I blogged previously on doing so for LINQ, but hadn't had the opportunity to work out the details for one of the other new technologies I'm using, ATLAS.

Thanks to an excellent posting by Jay Kimble, I don't have to!

In his post "How to Add Atlas to an existing site (For Brendan)", he details step-by-step what's needed to add ATLAS support to an existing ASP.Net web application.


Wednesday, May 31, 2006

The problem with beta software libraries

I'll admit it - I'm a serial early-adopter. I was man/mad enough to actually try using Windows Vista Beta 1 for over a whole month as my main workstation OS both at home and at work, and wasn't put off enough not to be considering doing again with Beta 2.

But the problem is compounded when you want to get ahead with new technologies like Windows Communications Foundation (formerly Indigo) - as the library is refined, there are inevitably times when "things change".

For WinFX this seems to have been the norm rather than the exception case - the Windows Workflow Foundation book I bought to help me get going is already out of date in a number of key areas (tho' it does a great job of introducing the concepts). Worknig with WCF, my problem was that the config schema changed between the Jan CTP and the Feb CTP, making the majority the WCF samples on the net incorrect.

To make matters worse, Feb CTP installation does not update the configuration schema, therefore the intellisence will not match the changes that were made in that version - so you don't get any help from VS.

Fortunately, in this post, "WCF configuration schema", Guy Burstein provides not only a reminder about the problem with breaking changes, but also a fix for the problem with a revised schema file to load into Visual Studio.
"forums.microsoft.com to the rescue once again!" shouted Little Cook.

Friday, May 19, 2006

Sahil Malik - blah.winsmarts.com

I've just found the blog of Sahil Malik of Winsmarts.com and in particular a set of postings in which "intend to bring C# 3.0 down to earth".

I'm impressed - by focusing on the smallest language feature possible and covering it in a practical sense, he does a great job of explaining some of the new language features of C# 3.0.

The first 3 postings are:
Part 1: Implicitly Typed Local Variables

Part 2: Anonymous Types

Part 3: Extension Methods

More good stuff to read, and it's well worth subscribing to his blog feed too.

Karl Seguin [MVP] : Have I inherited a disaster?

In his blog on CodeBetter.com, Kark Seguin provides a very useful list of simple searches to run against anyone else's code you have foisted upon you.

To quote from his posting:
"Have I inherited a disaster? I hate taking over someone's bad code. The projects always go on forever and you are forced to follow bad practices to try and string together fixes and features without it all crumbling down. There are some quick, not always 100% accurate, ways to know whether you've inherited a disaster"
It's an excellent read, and a good aide-memoire because it brings such a quick way to check for best (or worst) practice.

You can find the posting here.

Tuesday, May 16, 2006

.Net code generation strikes again...

In his blog, Stephen Kaufman shows a nicely worked example of using CodeDom to Programmatically Create Windows Workflow Rules.

What makes this interesting is not only does it provide a solution to a real-world problem, but it also re-enforces the underlying nature of .Net - i.e. that .Net code gets compiled into MSIL which the runtime executes.

Definitely worth a read.

Thursday, May 11, 2006

Migrating .Net 1.1 to 2.0

Peter Laudati has just posted a great "Four FAQ overview of some of the issues involved with doing a .NET 1.1 to .NET 2.0 migration. The ASP.Net migration guidelines in particular present include a wealth of MSDN and other technical references - including our old favorite the Web Application Project Template.

Excellent stuff.

Wednesday, May 10, 2006

ATLAS Toolkit Update

Well, my fix didn't make it into the ATLAS Toolkit directly, but the latest refresh does provide a fix for the problem I blogged about before.

The refresh is worth getting not ony for the fixes, but also for the new controls it gives. Probably the most interesting is the Modal Dialog Extender. This little beauty lets you use any panel on a page as a modal dialog, rendered as a floating panel with the rest of the page grayed out and inaccessible. Very nice!

VS2005 Web Application Project v1.0 released

I've blogged about this before here and here, but it's definitely good news that Scott Guthrie has announced that
VS 2005 Web Application Project V1.0 has been released.

Having now worked extensively with the "Whidbey" web project model, I'm glad that this alternative is available and supported. I have a feeling that the Web Application Project model is actually going to be the more used - at least amongst the professional development community - as it provides much more control over the structure of your project.

As always, this is my 2p and your mileage may vary.

Tuesday, May 09, 2006

Closing the circle... Finding that missing Linq

I've been looking at Linq recently in the context of using it in anger to provide in-memory filtering of List<thing> instances.

My problem was that I had an existing class library project that I needed to "Linq enable", and just adding the references to System.Query et al just doesn't work.

It turns out that you need to modify the project file itself.

You can do this in any text editor easily enough, but I found this trick for doing so in VS2005.

  1. Right click on the project in the solution and select "Unload Project"
  2. Then right-click again and select "Edit project file" from the context menu to open the project file up in the editor. This gives you all the benefits of syntax highlighting, intellisense, etc. Good stuff.
  3. Make your changes to the .csproj file and save 'em
  4. Right click on the project in the Solution Explorer and select "Reload project"

Now, to Linq enable a project, you need to find the line in the project file that reads

<import project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

and replace it with the following lines

<import project="$(ProgramFiles)\LINQ Preview\Misc\Linq.targets" />
<!-- Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" / -->

Of course, your path to the Linq.targets file may be different if you've installed Linq anywhere other than the default.

Recompile your project and you'll find that all the Linq goodness is available and working within your existing project.

Wednesday, April 26, 2006

Web custom controls - changing the base tag

In this blog entry "A detail the Webcontrol books don't teach you", Miguel Castro tells you how to override the default behavior of a web custom control and replace the SPAN that is generated with a DIV (or any other tag!), and points out the differences needed when your control inherits from System.Web.UI.CompositeControl rather than System.Web.UI.Control.

Amazing how Googling (in this case for "web custom control render div not span") can give you exactly the answer you were after!

Fixing ATLAS Control Extenders

ATLAS is a really nice piece of technology, allowing you to AJAX enable an ASP.Net page. The recently released ATLAS Control Toolkit provides a suite of ATLAS controls that are useful out of the box, and provide a good set of samples for developing your own.

Of course, the problem with using any third party control is that you may have trouble when the control doesn't work in quite the way you expect.

I've been having a problem with the Popup Control Extender recently. It's a control to let you use one control on an ASP.Net page to toggle the visibility of another - and being part of the ATLAS Control Toolkit, it's fully ATLAS enabled and so renders the behavior on the client.

The problem was that the designers of the toolkit didn't consider the case when the extender was used in a composite control that was repeated on a page. The toolkit renders markup on the page for behavioral properties exposed from the extender, but wasn't catering for when the extender was itself repeated as part of a composite control.

Fortunately, the source code for the Popup Control Extender comes with the ATLAS Control Toolkit itself, so I was able to fix the fault myself - score one for open / shared source!

I posted the full fix in the ASP.NET Forums - hopefully others will find it useful. I'm just made up to be able to contribute something back for a change!

Friday, April 21, 2006

Getting at HttpServerUtility

Here's the problem - you want to HTML encode some content in a class library that supports your ASP.Net application... You could write the routine to HTML encode a string yourself, or you could re-factor your code to do the encoding in the page code-behind like this:
public partial class DemoPage : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
LabelControl.Text =
Server.HtmlEncode( LibraryClassInstance.Content );

// rest of the implementation goes here
But what if you're abstracting things so that a library object has to be able to render itself as HTML?

The problem is all about getting at the HtmlEncode method if you've not got a Server object handy. The Server object is actually a singleton instance of the HttpServerUtility class exposed by the ASP.Net environment from the HttpContext in which the page is running.

HOWEVER, the HttpContext class exposes a static method to return the current context instance, including the associated HttpServerUtility instance, so all you have to do in the library is the following
namespace demo
class LibraryClass
public string GetHtmlSafeContent()
return HttpContext.Current.Server.HtmlEncode(this.Content);

// remainder of the implementation goes here
Voila - HTML (and URL) encoding and de-coding at your fingertips.

Design-time goodness: ImageUrls

When you're developing web server controls, how often do you expose a Url or an ImageUrl property? Chances are that it's one of those tasks that happens 9 times out of 10, as adding image support to an existing or composite control is that common a task.

In this forum post, Steven Cheng from MS support gives a good code-snippet for a property that has the default ImageUrl designer applied to it. Unfortunately, he neglects to point out the assembly references needed to get it to work.

To use the standard designers requires you to reference the System.Design.dll assembly in your control library, and then to add the using statements highlighted in the sample below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Design;
using System.Drawing.Design;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;

namespace DemoControls
[ToolboxData("<{0}:CoolButton runat=server>")]
public class CoolButton : ImageButton
[Editor("System.Web.UI.Design.ImageUrlEditor, System.Design,Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",typeof(UITypeEditor))]
public string RolloverImageUrl
String s = (String)ViewState["RolloverImageUrl"];
return ((s == null) ? String.Empty : s);
ViewState["RolloverImageUrl"] = value;

// rest of the implementation goes here...

Adding this kind of design-time support is a snip, and makes those simple extended controls much more usable.

Tuesday, April 18, 2006

Source Code for the Built-in ASP.NET 2.0 Providers Now Available for Download

In his blog, ScottGu today announced:
Today we released the source code for the built-in ASP.NET 2.0 Membership, Role Management, Site Navigation, Session State, Profile, Web Events, and Web Part Personalization providers

This is a great thing - not only is Microsoft being much more helpful by providing sample code to let us develop (in this case) pluggable providers, but rather than releasing ????? code which just demonstrates the concepts, they're releasing the production code that we're already using.

The ASP.Net developer centre also great documentation on the Provider design pattern/model, and the individual provider types used by ASP.Net 2.0.

Finally, they've also released this under the Microsoft Permissive License (Ms-PL) - a license that allows and encourages the development of derivative works.

I for one can see myself using all of these types of providers at some point or other in my current project, so these samples are going to make my life much easier. Good stuff.

Thursday, April 13, 2006

VS2005 Web Application Projects hits RC1

I've blogged about this VS2005 add-in before, as it provides a much better migration experience for complex web applications.

But today Robert Shelton posted that the add-in has now reached RC1. This is a good thing, as a (nearly) production ready toolkit for migrating "old" ASP.Net 1.1 web applications is sorely needed.

You can read his blog post here and get the download here.

Moving a development team forward - "scrimages"

In this blog article, David L details how he implemented a "Developer training regime" at a client in order to move the team's .Net development skills forward and prepare them to migrate to ASP.Net 2.0.

Apart from the (slightly dubious) American Football metaphor, the concept is remarkably similar to the Developer-to-Developer training that Angel Solutions and Mandogroup have already implemented, and that I intend on implementing here at In4Tek.

The article makes a good read, however, and is a timely reminder about the value of your developer's skill-sets and keeping them up to date, but also serves as a reminder that the training should perhaps have rather more focus on the end goal (in this case of migration) than be open-ended as the Mandogroup training has been thus far.

Check the article out here:


Columbus would have been proud - extending the ATLAS

The ATLAS group have been busy - today they announced the release of the ATLAS Control Toolkit. From the introduction.
The 'Atlas' Control Toolkit is a collection of samples and components that makes it easier then ever to build and consume rich client-side “Atlas” controls and extenders. The toolkit provides both ready to go samples and a powerful SDK to simplify the creation and re-use of your own custom controls and extenders.
As always, the best way to evaluate at a toolkit like this is to look at the samples provided, and the ATLAS toolkit doesn't disappoint, with 9 new controls and extenders that cover some of the most common AJAX features you'd need to make a site provide a rich and dynamic experience.

My particular favorites include the PopupControl and the ReorderList - paired, these two would provide an editing experience for simple data (such as lookup table data, for example) almost as good as could be achieved with a Windows Forms client.

More later, but I can see myself using these, and the guides for developing your own ATLAS controls and extenders extensively over the next little while.

Wednesday, April 12, 2006

Mix-and-match Unit Testing

In this MSDN Magazine article, John Robbins presents a tiny little hack that could save a huge amount of time if you're migrating a .Net 1.1 application with NUnit tests to .Net 2.0 and Visual Studio 2005.

The hack basically involves using some compile tests to switch between NUnit and VS2005 native testing.

The code he cites was actually found in the Patterns & Practices group Composite UI block source and is remarkably simple, requiring just the following code at the head of every test class and a change from using [Test]attributes to using [TestMethod]attributes instead.
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
Nice when you find a simple solution to an apparently intractable problem!

Tuesday, April 04, 2006

Developer Highway Code

My colleague Andrew Lightowler spotted this in the security section of the UK MSDN site today. The Developer Highway Code: provides a checklist of security issues that every .Net developer should keep in mind when planning and implementing a piece of software. From the introduction:
To build software that meets your security objectives, you must integrate security activities into your software development lifecycle. This handbook captures and summarises the key security engineering activities that should be an integral part of your software development processes.
At over 170 pages, it's fairly heavyweight, but well worth a read, particularly in concert with Writing Secure Code (which you can, of course, get from Amazon).

I do, however, wonder how well (or more likely badly) some of my old code would fare against these checklists!

Friday, March 24, 2006

Six pillars of AJAX application design

AJAX and ATLAS are two hot topics in the arena of web application development.

In this blog entry
, RickSP covers a talk he presented at Mix'06 on how to "Design a Better User Experience with AJAX and ATLAS", and in particular, six "lessons from the trenches". My take is that these should really be "Six pillars of AJAX application design".

The two sites he references on AJAX Design Patterns and AJAX (XMLHttpRequest) Usability are an excellent read too.

Enterprise Library 2.0 extensions.

In his blog, Tom Hollander highlights some "bloody cool Enterprise Library v2 Extensions".

Whilst mostly related to the configuration of EntLib (but including a package that integrates the config tool with VS2005), one of the comments provides a link to a Data Teir Generator for EntLib.

I think that this could be a really simple way of getting started with the EntLib - bringing it closer to the data teir functionality of Castle ActiveRecord (and its associated generator) or IdeaBlade DevForce.

YET ANOTHER toolkit to evaluate! *sigh*

Thursday, March 23, 2006

ASP.Net on Rails

There's been a lot of excitement recently in the Open Source community about Ruby on Rails. This web development framework makes developing web applications much easier by providing a well structured Model/View/Controller framework in which to develop.

Of course, having this kind of framework available to ASP.Net would be even more exciting, the MonoRail project was a great find. Part of the wider Castle Project, it provides a true separation of presentation from business logic and persistance of data.

There's a nice database persistance layer as part of the project, too - ActiveRecord. Great for .Net 1.1, but possibly with some issues under .Net 2.0 as it relies on untyped collections. But I've found that there's a good article on implementing nicely typed collections for related objects tho, here, so I'm now less worried about using ActiveRecord as the persistance layer.

I'm going to try implementing a test with this later today, but it looks good from the documentation. There's even a stud for documentation about implementing the Inversion of Control pattern using the Windsor Container within the framework - all very interesting stuff.

Whether I manage to integrate MonoRail with AJAX (maybe using ATLAS) will be the real kicker, of course, but if it can be done, I think this could be an extremely powerful development framework.

More later.

Friday, March 10, 2006

The Provider pattern... in .Net 2.0 AND .Net 1.1

The ASP.Net Developer Center on MSDN has thrown up another useful article - or actually a pair of articles - on the Provider pattern.

In this first article, Rob Howard describes how the Provider model is implemented in .Net 2.0, along with a worked example.

Providers are, to my mind, absolutely central in developing flexible software architectures - being able to "unplug" a default provider and/or "plug-in" your own replacement/extension is central to role management in .Net 2.0. But it's also a very useful pattern in it's own right. The Search engine I wrote as part of the Mando Common Platform uses exactly this pattern (although partly configured via a database as well as via the web.config) to allow "pluggable" search handlers to operate across a variety of data sources.

But what's more interesting is that in the second article, Rob provides a parallel implementation of the provider pattern in .Net 1.1 - in the process clearly explaining how the pattern can be implemented in .Net 1.1.

This pair of articles really should be required reading at Mando for the programming team!

An Alan Partridge moment - VS2005 Web Application Projects


I just found this page on MSDN - a Beta version of an add-in for Visual Studio 2005 that allows it to work with web projects the way it used to in VS2003.

Looking at it, this should make migrating existing ASP.Net 1.1 projects to .Net 2.0 a tad easier by removing all the faffy refactoring that was needed to match the new coding model.

Actually, pretty much every posting on the ASP.Net Developer Centre: Infrastructure page is relevant right now - from the Web Standards support to the new Web Deployment projects. The use of the former is obvious, whilst the latter seems to take the Publish Web Project idea to the next level with web.config customisations and all sorts of goodness.

Time to find a simple ASP.Net 1.1 project and try converting it...

Wednesday, March 08, 2006

I have seen the future... and it is LINQ

I'm astounded... Really gobsmacked...

I've just watched this Video interview on Channel 9. In it, Anders Hejlsberg describes LINQ (Language INtegrated Query). A part of C#3, but already available as a technical preview, this brings SQL type querying to ANY object that implements IEnumerable.

That means pretty much EVERYTHING! I'm still trying to get my head around it all, but Anders' demo of iterating the instance methods of the string type using the syntax was the epiphany moment for me - a simple, elegant way of accessing complex real-world data. Wow!

The LINQ Project home page is available here:

The technical preview is available here:

Tuesday, March 07, 2006

Unit Testing snippets for VS2005

Having just touched on NUnit testing in a training presentation at Mando Group Ltd, it was perfect timing that I ran across this article posted to TheServerSide.Net.

Snippets seem to be a great addition to VS2005, allowing templates for common code to be pulled from a common store - great for implementing coding standards and best practices.

These snippets provide the framework for generating unit test classes running under both NUnit and Microsoft Visual Studio Team Server.

This is one set of snippets that I'm definitely going to be installing.

Saxon - providing an exciting " Hello World" implementation?

This post by M. David Peterson on the O'Reilly weblogs (and cross-posted to both XML.com and the Windows DevCentre) provides a fully-commented ASP.Net "Hello World" implementation.

Nothing exciting there, except that it's demonstrating using the Saxon 8.x XSLT processor to transform XML and XSLT into XHTML. What caught my attention was that Saxon provides XSLT 2.0 support, unlike the System.Xml.Xsl classes in .Net 1.1.

I've not tried this myself yet, but given the grief I've had with managing namespaces in XSLT 1.1, I'm hoping that Saxon might make using XSLT for the generation of dynamic content rather easier. Certainly, it would provide a stop-gap implementation until full XSLT 2.0 support is provided out of the box in .Net.

Saxon is available as a basic (non schema aware) version as OpenSource from SourceForge, or as a schema-aware version from Saxonica. Priced at £250 / workstation or server, it's reasonably cheap too.

Another item for the research list!

Monday, March 06, 2006

WSCF 0.6 Released

Thinktecture's Christian Weyer and Buddhike de Silva have released the latest version of this excellent toolkit. Now for .Net 2.0 and VS2005 only, in my mind this really is the optimum way of defining and coding web services across corporate boundaries.

The Web Services Contract First methodology is really a return to the original spirit of web services - that of an interface driven service oriented architecture. By providing all the tools to let you generate the WSDL contact first, this toolset makes you think about the interface between services, rather than the traditional VS driven way of just exposing your existing classes through a webservice.

I blogged about this before after going to a presentation on this by Christian, and am still as impressed - I just can't believe I missed the 0.6 release until now!

More information and the download links can be found at http://www.thinktecture.com/Resources/Software/WSContractFirst/default.html.

Thursday, March 02, 2006

Open Source vs "Commercial Reality"

In this OnLAMP article, Andrew Stellman, Jennifer Greene, authors of Applied Software Project Management, make some interesting comparisons between the corporate software development process and that of the Open Source community.

Whilst the article is unashamedly a plug for their book, it does highlight deficiencies that seem to be prevalent in the corporate world, where commercial constraints often put pressure on a project team to deliver "the product", causing other deliverables - in particular things like documentation, testing, architecture, etc - to be given less weight than they perhaps otherwise should. The practices and patterns that should be applied across the project getting subverted by the commercial "realities".

In the article, they detail five
principles for successfully delivering a project, namely:
  • Tell the truth all the time
  • Trust the team
  • Review everything, test everything
  • All developers are created equal
  • The fastest way through the project is to do it right
In my opinion, as an Architect and Developer, the two that get least weight are the "Review everything, test everything" and "The fastest way through the project is to do it right".

These, particularly the latter, should be championed much more. Time and again, I've found I've had to argue in favour of a bit more complexity and cost for a feature in order to future proof it or provide a foundation for future work, against the drive to deliver "just what's needed as soon as possible and as cheaply as possible".

Inevitably, if the product in question is going to have a future beyond its first release, then thinking about that future, and the possible changes or extensions to its functionality, and putting foundations in place to support that future give long-term cost benefits that far outweigh the short-term savings that a "sub-optimal" solution would bring.

The article can be found here:

Service Oriented Archictecure - The City Metaphor

In this article on MSDN, Pat Helland provides an interesting metaphor "for the evolution of information technology into the world of service-oriented architectures".

In it he compares the evolution of cities and the real-world systems that exist within them (transport, manufacturing, etc) with that of SOA, in the process providing a pretty good introduction to the subject. From the summary:
Explores the idea that information technology is evolving in a fashion similar to how American cities have evolved over the last two centuries. The opportunities and pressures of the technological revolution have driven our metropolises to adopt new frameworks, models, and patterns for commerce and communication. Recent developments in IT are analogous. What can we learn about the present and future directions of IT by studying the recent history of our urban centers.
Well worth 10 minutes of your time to read.

The full article can be found at http://msdn.microsoft.com/library/en-us/dnmaj/html/aj2metrop.asp.

Patterns & Practices Summit

I've been going on about Patterns & Practices for a while now, so I was greatly interested to discover the day-by-day coverage of the Patterns & Practices Summit West 2005 on TheServerSide.NET.

Paul Ballard and Gregory Hoyt give a good account of each of the three days (1, 2, 3), including relevant resource links. The Enterprise Library 2.0 powerpoint is well worth a look, particularly if, as I do, you think that a community-driven best-practice library can significantly reduce development effort.

Would I want to go to an event like this? Certainly. Should there be something like this in the UK? Definitely.

Now, I just have to work out how to get to go to the Oslo event in May!

Friday, February 24, 2006

Building a WaitScreen control for ASP.NET

Another day, another nuggetty article, this time about ASP.Net user interface best practice - namely in providing a "Wait Timer" when a page has some long-running processing occurring on it.

Scott Guthrie must do nothing but blog all day (lucky beast! :) ) - in this post, he links to a very nice article by Daniel Fisher which includes the source code to a server control that lets you show a "Wait" graphic. To quote his reason for needing this functionality:
"Sometimes it happens that a form is processing and you need to make sure that the users don't panic and run away before it finishes."
Phil Winstanley pointed out in this blog entry that this kind of thing isn't necessarily applicable or suitable when a page is using AJAX for it's processing, and gives a number of reasons.

I still think that the simple elegant implementation of this control makes it a good one.

Thursday, February 23, 2006

ASP.NET 2.0 RSS Toolkit

Here's another useful .Net 2.0 code library, which I found linked from this MSDN blog post by Scott Guthrie. It provides flexible, configurable RSS functionality for both consuming and generating RSS feeds.

Scott's posting provides a great step-by-step tutorial on the basics of using this, including screen shots - excellent work.

RSS syndication is becoming pretty much pervasive, so making supporting it this easy can only be a win.

The RSS Toolkit for ASP.Net 2.0 can be found here, and is definitely one to add to the toolbox.

Wednesday, February 22, 2006

Shy Cohen's WebLog : It’s playtime! The WCF Virtual Labs are now online!

The MSDN Blogs are a treasure chest of information, and great for telling you when Microsoft releases new resources. One of their more interesting offerings are the MSDN Virtual Labs - online lab sessions that guide you through new technologies. I played with the VS2005 and BizTalk labs at the Launch event this year, and was reasonably impressed.

Today, Shy Cohen posted in his blog that "MSDN Virtual Labs for WCF are up on http://msdn.microsoft.com/virtuallabs/wcf/. These are the same labs we use in the training we deliver here at MS."

'Nuff said really - as he puts it... Playtime!

Windows Communication Foundation Web

WCF is going to be central to any windows-based distributed systems development over the next year or so... and here's a fine resource for it.

The Windows Communication Foundation Web: is a community site sponsored by Microsoft to provide peer suport and insight into using the new Indigo technologies.

I also have to admit that MSDN seems to be getting it right by involving the wider development community earlier and closer.

New Year, New Blog

I'm starting this second blog as one that is much more focused on those technical nuggets of information that I come across and want to both keep and share with my peers.

I'm know going to be doing a lot of linking to the MSDN Blogs, but will also try and research the wi(l)der web for those hard to find nuggets of information, as well as posting my own thoughts on and solutions to technical problems.

Watch this space!