Back in 2006, I wrote an article entitled Roll Your Own Tile Server for Via Windows Live.
The code sample was pretty popular, but Virtual Earth became Bing Maps and the SDK has improved massively over the years so the article and the code are a little dated.
This is the updated code sample which runs under Visual Studio 2010.
Rob Blackwell
September 2010