Friday, December 12, 2008

How to delete a file permanently!

Have you ever noticed that copying a large file on Windows NT can take a really long time, but deleting the same file will happen almost instantly? Actually, when you delete a file, Windows simply deletes the index for the file and the file content remains encoded on disk. The space that the file occupied is not zeroed, so it's possible for raw disk editors and recovery tools to restore the file. So how can you permanently delete a file on disk? The answer is to use SDelete - another SysInternals tool by Mark Russinovich.

Click here to read more and to download a copy of SDelete.

Tuesday, December 9, 2008

What is a Shim?

Have you ever written a shim? Chances are that you have, you just don't know it yet. Here's the definition on Wikipedia:

"In computer programming, a shim is a small library that converts one API into another. They typically come about when the functions of one API become part of another, larger, library. In these cases, the older API can still be supported as a thin layer on top of the newer, and more general, code." Wikipedia

Tuesday, December 2, 2008

How Device Drivers Work

Take a look at the following link for a high level article on how device drivers work. I found the section on driver ranking to be especially enlightening.


Sunday, November 30, 2008

South Park Studios

You can actually watch all the South Park episodes online at Here's the URL for Hell on Earth 2006...

Wednesday, November 19, 2008

Yahoo! unveils new CEO search

Yahoo! is looking for a new CEO after an announcement today that cofounder Jerry Yang is stepping down from the top job as soon as a replacement can be found. This latest news comes just days after Google pulled out of an advertising partnership with Yahoo due to anti-trust concerns. It's hard to believe that the two events are unrelated. Perhaps this is a move designed by the Yahoo! board to entice Microsoft back to the negotiation room. Yahoo stock is currently trading at $10.60, well below the $33 a share offered by Microsoft back in May. $33 now looks quite optimistic but I doubt shareholders would be willing to accept a significantly lower offer. Only time will tell. Microsoft CEO Steve Ballmer has openly denied that Microsoft is still interested in a takeover.

Tuesday, November 18, 2008

Windows Internals, Fifth Edition

It looks like Mark Russinovich and David Solomon will have a new version of Windows Internals available in the first quarter of 2009. This fifth edition will be updated for Windows Vista and Windows Server 2008. I understand that Alex Ionescu has also contributed to the book. You can preorder a copy on Amazon.

Monday, November 17, 2008

More on Windows 7 Client Features

Here's a pretty comprehensive review of the features available in the M3 build of Windows 7. Take a look at the videos.

Friday, November 7, 2008

Windows 7 M3 Screenshots

Some screenshots of the Windows 7 Milestone 3 build have emerged on CNet, presumably taken during WinHEC this week. Milestone 3 is the last major build before Beta.

Thursday, November 6, 2008

Antitrust concerns kill GoogleY!

GoogleySteve Ballmer must have been smiling over his breakfast cereal today with the news that Google has pulled the pin on a search-ad partnership with Yahoo due to antitrust concerns.

Microsoft offered to buy Yahoo earlier this year but the deal was rejected at $33 a share. Yahoo shares are currently trading at just under $14. Perhaps this latest news will renew merger talks.

Tuesday, November 4, 2008

RDP Performance Whitepaper

How well does Remote Desktop Protocol (RDP 6.1) perform in Windows Server 2008 and Windows Vista? Read all about it in this RDP Performance Whitepaper.

The whitepaper quantifies the bandwidth requirements for ClearType font in different applications and for Desktop Themes with varying color depths. It quantifies the bandwidth required by the compositing DWM in Windows Vista and describes the bulk compression options in RDP 6.1.

The whitepaper is quite a good read if you're interested in using RDP in low bandwidth environments. You might consider disabling ClearType, using the Windows Classic theme and reducing your color depth down from 32bit.

Visual Studio 2010 CTP

You can now access the Visual Studio 2010 CTP over at Microsoft Connect. Click here for the download page. The CTP is pre-installed in a virtual machine so you'll also need a copy of Virtual PC 2007, also free to download.

Monday, November 3, 2008

New to working with Windows PowerShell? You might want to take a look at the open source script editor available from The tool is free to download and there are a number of power packs available to automate many common tasks. One recent power pack provides Hyper-V management capabilities and will save you a lot of time when working with virtualization. Happy scripting!

Thursday, October 30, 2008

Visual Studio 2010

Click here or on the image below for an overview of Visual Studio 2010 and .NET Framework 4.0. I heard rumors that a pre-Beta CTP was externally available for download, perhaps via Microsoft Connect. I'll won't get to use it anyway because my team uses Source Insight. Don't read anything into that though! Visual Studio is the tool of choice for working with .NET and Team System.  The application lifecycle tools in VSTS 2010 look really good!

[11-4-2008: The rumors are true. You can access the CTP on Microsoft Connect.]


Wednesday, October 29, 2008

Windows 7 Public Debut

So Windows 7 had it's first public showing this week at the PDC conference in Los Angeles. Here's an article about it in the Seattle Times. One of the things that strikes me about Windows 7 is how lean it is! MS has trimmed a lot of fat from Vista, removing applications like Contacts and instead making them available as Live downloads. The OS just feels lighter and sleeker, even running with VDI, the whole experience is very responsive. The disk footprint is low and the OS installs faster than expected.

Sidebar has been reworked so you can position gadgets anywhere on the desktop. The task bar has had a major facelift too! Now you can pin running programs and documents so you don't really need the quick launch toolbar. Overall, the interface is more inductive.

UAC is configurable so you can limit the number of elevation prompts when running as an Administrator. The default setting is to only bother you when a program attempts to modify a protected resource but you can adjust this using a sliding scale, similar to Internet Explorer's security tab. This is probably the best improvement on Windows Vista.

However, many of these features are cosmetic and since Windows 7 is still alpha, things will be different in the RTM. But the overall picture will stay the same with improvements to performance,  compatibility, stability and security. It looks really good.

As someone who was hit twice by SLAMMER on XP, I really appreciate the security enhancements in Vista including the phishing  & spyware detection, firewall, resource protection, UAC and session isolation. Windows 7 makes this medicine a lot easier to swallow.

Technorati Tags: ,

Monday, October 27, 2008

Google Android

It was only a matter of time...

Technorati Tags: ,

Session Isolation for Services and Devices

While reviewing a software design specification this morning, I noted that Windows Vista enables session isolation for services and drivers. This is just another way that Vista provides a more secure operating environment than earlier versions of Windows, including Windows Server 2003 and Windows XP. Here is a link to a useful whitepaper if you'd like a high level understanding of how to modify application and driver services to run in Windows Vista.

Prior to Windows Vista, all services would run in the session of the first user who logs onto the machine. The first session is called session 0 and the unfortunate side effect is that applications have ready access to services that are running with elevated permissions. Windows Vista mitigates this security risk by isolating services in session 0 and making this session non-interactive. The first user who logs onto the machine is granted session 1, as shown in the diagram below. Services running in session 0 do not have access to the video driver, so any attempt to render graphics fails. This is one reason why many print services did not initially work in Windows Vista.

Services and applications must communicate using remote protocols, such as RPC, rather than via Windows Messages. However, Windows Vista provides some basic APIs that allow session 0 services to create a message box on a user desktop and to create a process in an interactive session. Obviously, this architecture shift created some compatibility problems for many software vendors but the net affect is a more secure operating environment.


Cyril Voisin has published an excellent article on this subject if you require a deeper understanding.

Friday, October 24, 2008

Windows Vista Service Pack 2

It looks like Microsoft will release a second service pack for Windows Vista before Windows 7 RTM. You can expect SP2 to be very similar in nature to SP1, few or no new features, primarily bug fixes and performance optimizations.

It's confusing because Windows XP Service Pack 2 was such a tremendous change and introduced many new features. You almost expect a second service pack to include more than just bug fixes. In actual fact, XP SP2 included code from the original Longhorn source, so it was practically a major release. Microsoft could have slapped the Energy Blue Theme on the desktop and shipped it as Windows XP2.

However, things have changed within the Windows group at Microsoft. The team is using a revised software development lifecycle with a goal of releasing a new version of both client and server every 2 years. It's certainly working with the group on schedule for Windows 7, so get used to the idea of smaller service packs.

A final word on Internet Explorer 8 - install beta 2 and start using it now. I'm not saying that IT should roll it out with WSUS but it's great for use at home and even the office. Click the screen-shot below and try it out.


Wednesday, October 22, 2008

Ring Buffer

During a recent interview, I was asked an algorithm question about buffering data with circularly linked lists. The problem wasn't especially difficult, just some pointer arithmetic so I won't relay the details here, but I remember wondering about useful applications for cyclic data structures. First-In-First-Out (FIFO) queues are an obvious application, but if a Windows kernel developer is taking the time to ask, there's got to be something behind the question.

So I was reading a design specification the other day for a virtual device driver and stumbled upon the following, written by another Windows developer:

"...the [virtual device provider] and [virtual device client] act as endpoints on a VMBus channel and communicate using upstream and downstream ring buffers."

All of a sudden, a light switched on. Here's what wikipedia has to say about Ring Buffers. Circular data structures are especially useful for streaming data between sockets. In my case, here is the most pertinent point:

"An example that could possibly use an overwriting circular buffer is with multimedia. If the buffer is used as the bounded buffer in the producer-consumer problem then it is probably desired for the producer (e.g., an audio generator) to overwrite old data if the consumer (e.g., the sound card) is unable to momentarily keep up."

The wikipedia article has a POSIX implementation of a ring buffer if you'd like to try it out.

How to Debug VBScript

Windows Script Host (WSH) is the standard scripting environment on all versions of Windows since Windows 98. You can use it to execute scripts written in a variety of languages, JScript, VBScript, Perl, Python - any language that has a compliant WSH engine. WSH will more or less be superceded by PowerShell V2 which will ship with Windows 7 - there's even a cool new Integrated Script Environment (ISE) in the box. However, WSH will still be around for a while and it's a simple solution for working with Windows Management Interface (WMI) so I figure it's worth a mention.

If you're working with VBScript or JScript and running within the Windows Shell , debugging is a piece of cake. Just pass /X on the command line to cscript.exe and WSH will break into the debugger. Make sure you have Visual Studio or similar installed.

cscript.exe /X myScript.vbs

Monday, October 20, 2008

Rebuild the BCD Store

I was testing some different debug settings today with the Windows Boot Manager on my development machine and accidentally set the debug transport provider to a non-existent DLL. This is pretty easy to do when using the BCDEDIT utility on your Windows Vista machine so be warned. Once I restarted my machine, Windows would no longer boot and I couldn't even enter safe mode. My only option was to rebuild the Boot Configuration Data (BCD) after booting from a Windows install disk and entering the recovery environment.

If you find yourself in a similar situation and have corrupted your BCD, the steps to recover your machine are pretty straight forward. First of all, you need a copy of a Windows Vista Install disk. If you can't find one of these, you've got a problem!

  1. Restart your machine, enter the Bios <F2> and make sure you can boot from CD/DVD.
  2. Insert your licensed Windows Vista Install disk
  3. Once Windows Vista boots, choose Repair your computer
  4. Choose Advanced recovery options and click Command Prompt
  5. At the console, enter bootrec /rebuildbcd
  6. Restart your computer

If the rebuild does not succeed in the above, you will need to remove the current BCD before attempting to rebuild. Here's what to do:

bcdedit /export c:\bcd.bak
rename c:\boot\bcd bcd.old
bootrec /rebuildbcd

Good luck! :)

Windows Mobile 6.0 GPS

A few weeks ago, I posted about my HTC TyTN II with Windows Mobile 6 and said that I'd follow up with a review of its GPS capability. I've installed Google Maps for Mobile on the device and I'm really impressed with the available features, however, it's not a useful driving aid. Google Maps for Mobile doesn't have audible directions and my AT&T Tilt doesn't have a dash mount. In short, I'm really glad, I also bought a Garmin Nuvi for GPS navigation while driving.

That said, my Windows Mobile 6 HTC has well and truly exceeded expectations. Even my wife wants one! It's the best way to Skype/IM/Facebook/Email/Call/SMS your friends when you're on the move.

Windows Kernel Debugging

Most Windows developers are familiar with the debugging functionality inside Microsoft Visual Studio and have few troubles stepping through code and using the watch windows. Visual Studio works great for the majority of applications which run in user mode on both local and remote machines. It also supports pure managed debugging,  where all the runtime details are hidden, simplifying debugging for .NET developers. Best of all, you don't need to leave the comfort of your IDE to attach a debugger and locate symbol files.

Microsoft also offers a number of stand-alone debuggers including CBD, NTSD, KD and WINDBG. These debuggers are included in the Windows SDK and you may also download them from the WHDC portal. Most user mode application developers will never want to use these stand alone debuggers because they expose a lot of information through a console interface. However, Visual Studio does not support kernel mode debugging and therefore has limited application for driver developers. This is where the stand-alone debuggers come into play.

If you'd like to learn more about debugging device drivers, the WHDC portal is great place to start. I'm not going to describe the inner workings of any particular debugger. However, I would like to describe how to setup a remote kernel debugging session using Firewire (IEEE 1394 interface) and KD. You can also debug using a serial or USB cable. For more details, I recommend  this MSDN article.

To start off, you will need a Firewire cable and two physical machines with 1394 host controllers. The first machine is your development box which will HOST the KD debugger. The second machine is the TARGET, which will run Windows in debug mode. This article assumes that you are using Windows Vista or later on the HOST machine and Windows Server 2003 or later on the TARGET machine.

  1. Connect the Firewire cable between you HOST and TARGET machines.
  2. Install KD on your HOST machine. Note that there are 64 bit versions of the debuggers.
  3. You also need to install the 1394 debugger driver. The first time you start a KD session over 1394, you will be prompted to install this driver so make sure you run as Administrator.
  4. Open an Administrator console and set the following environment variables:
    set _NT_DEBUG_BUS = 1394
    set _NT_DEBUG_1394_CHANNEL = 44
    REM if TARGET machine is Windows Server 2003 or later
    set _NT_DEBUG_1394_SYMLINK = instance
    REM else if TARGET machine is Windows XP or later
    set _NT_DEBUG_1394_SYMLINK = channel
  5. Change to the debugger install directory and run the following:
  6. Install the 1394 debugger driver if prompted
  7. KD will display a message saying "Waiting to reconnect"

At this point, your HOST machine is ready to go. Now you need to boot your TARGET machine into debug mode. You can do this a couple of different ways; the first using BCDEDIT and the second using MSCONFIG. I'll show you both.

To use BCDEDIT, open an Administrator console on the TARGET machine and type the following commands:

bcdedit /debug on
bcdedit /dbgsettings 1394 channel:44
shutdown -r

To use MSCONFIG, open the start menu and type msconfig in the search/run box. Browse to the Boot tab and choose Advanced Options. Check the Debug box, change the Port to 1394 and set the Channel to 44. Save the changes and reboot the machine.

If everything is configured correctly, you should see the KD session connect when the Windows splash screen is displayed as the TARGET machine reboots. If it doesn't work at first, try reconnecting the Firewire cable and press <ctrl>/<break> in the KD console.


Tuesday, October 14, 2008

Windows Server Directions

So I hope everyone knows that Windows 7 is approaching Beta and if you're lucky enough to participate in the Windows TAP or to attend PDC or WinHEC, you'll get an early glimpse of the new features in this latest release. Everyone else outside MS will have to wait for the public Beta or RTM.

The Windows 7 source is compiled into server and client editions so you can expect to see staged releases for both of these products in the near future. If you'd like a better understanding of where the server edition is heading, I can recommend this excellent whitepaper over on the WHDC portal.

I think Windows XP users will be really impressed with Windows 7 client. Rest assured that MS has listened to your feedback and has made some subtle changes that deliver outstanding performance, rock solid security, and a great user experience. If you've been holding off on Windows Vista, you'll want to take a look at Windows 7.

Head on over to the unofficial Windows 7 News site for news, rumors and dubious screenshots. :D

Friday, September 19, 2008

Aeros Craft

Check this out. Lighter than air?

Windows Mobile 6

HTC-TyTNII I just bought a HTC TyTN II with Windows Mobile 6. It's really more like a PC than a mobile phone so I don't think I'll SMS anymore; just check my facebook status if you want to know what I'm doing! Anyway, I mostly bought it for the integrated GPS and mapping.

I'm told that Google Maps for Mobile works really well on this device (thanks Kristian) but I won't know until I get the phone because it needs to install a client. I've had a quick look at but I don't think it can give audible driving directions. If either of these don't work out, there's always Garmin Mobile XT. I also have a Garmin Nuvi so I'll write another post to compare the mapping and satellite navigation capabilities.

My previous phone was a Samsung BlackJack and I seriously considered upgrading to the BlackJack 2. The new Samsung also runs Windows Mobile 6, includes GPS, a slim and lightweight design, QWERTY keypad and great battery life. However, the proprietary connector for charge and USB is a real pain and without Wi-Fi, the decision to buy the TyTN II was pretty easy.

Now, all I need to complete my nerd disguise is a phone belt-pouch and pocket protector. I'm pretty sure they have those at the Microsoft campus store.

Wednesday, September 17, 2008

Microsoft Search Server 2008

Now you can download and use Microsoft Search Server 2008 Express for free. All you need is a Windows 2003 or 2008 server and you can start indexing all your content. If you like the free version but need more advanced capabilities, you might want to check out Enterprise Search from Microsoft.

Microsoft Mediaroom

So I was chatting to my boss today about Microsoft Mediaroom. Basically, Microsoft has created a system that enables digital television over IP. So what's the big deal with that? It means you can receive digital television via DSL with software decoding plus upstream that enables you to customise your viewing experience. BT and AT&T have both signed up to Mediaroom, with BT allowing you to use your Xbox to connect to the latest games and multimedia.

Check it out...


Looking to watch TV through your web browser? FANCAST has full TV episodes and movies that you can watch on demand. FANCAST is provided by COMCAST, one of the major US pay TV providers, and therefore has access to FOX, Disney, Showtime and many other networks. I'm interested to know whether FANCAST is available from outside the US. Drop me a comment either way.

Technorati Tags: , ,

Friday, September 12, 2008

Microsoft Campaign

"Just because a design uses inheritance and polymorphism, doesn't make it a good design." - Bill Gates

If you haven't seen it yet, here's the new Microsoft Commercial staring Bill Gates and Jerry Seinfeld.


Wednesday, September 10, 2008

Visual Studio 2008 Product Comparison


I needed to install Visual Studio 2008 at work today and one of the perks of working for MS is that you have full access to all the company's software (excluding video games sadly). So I was browsing through the list of Visual Studio Team System (VSTS) editions and was a little confused about the difference between VSTS 2008 Developer Edition and VSTS 2008 Test Edition. So I looked up the product comparison and realised that I really wanted VSTS 2008 Team Suite Edition, which includes everything. But if you don't have the same luxury, take a closer look at the product comparison to decide which version you need. 

Tuesday, September 9, 2008

My first day at Windows

So I've started work with the RDP team in Building 6 at Microsoft's Silicon Valley Campus (SVC).  The campus originally consisted of five buildings but another was added off site as an after thought. There's a five minute walk down the street to get to the cafeteria and Starbucks at lunch time but it's a pleasure to get outside in the California sun.


We share the building with Microsoft Research so there's a bit of competition for the foosball table throughout the day. Otherwise, they've given me a nice little office that I've been trying to make my own. Thanks to Alex and Virginia for the digital photo frame and for Isaac's painting.

Thursday, September 4, 2008

Google Chrome

So Google have a browser now...


Some Fun with F#

Chris Smith has blogged about an artillery game that illustrates some aspects of F# with WPF. Click here to take a look. It's pretty cool that you can define units of measure and determine the units for calculated values. If only NASA had this technology back in 1999...

Here's a good article on F# in MSDN Magazine if you'd like an overview.

Friday, August 29, 2008

Love and Marriage

I was lucky enough to marry the love of my life last weekend. Just a small taste because this is a tech blog after all...


Understanding WPF Routed Events

Did you know that MouseDown is a bubble event and PreviewMouseDown is a tunnel event? Bubble and tunnel are actually two of the available Routing Strategies used by Routed Events in WPF. If you think of a user interface as a hierarchy of visual elements, bubble events propagate from a source element up the the visual tree until they are either handled or reach the root element. Tunnel events go in the opposite direction, starting at the root element and traverse down the element tree until they are handled or reach the source element for the event. These concepts are key to understanding WPF Routed Events.

There is a great article in the current edition of MSDN Magazine about Routed Events and Routed Commands. Read it for a better understanding of these two WPF technologies.

Wednesday, August 13, 2008

Visual Studio 2008 Sp1

Visual Studio 2008 Service Pack 1 and .NET Framework 3.5 SP1 have shipped! Get your download here...

Tuesday, August 5, 2008

Live Mesh Tech Preview

You've probably already heard about Live Mesh but you may not know that there is a tech preview available. Take the tour to learn more before trying it out. Certainly an interesting way to synchronise and share files between your computers and with your friends. A college pointed out that Apple have a similar system called MobileMe. I wonder whether Live Mesh uses an operational transform to enable group editing of mesh documents? Changes to documents are synchronised using FeedSync, which is an extension of RSS and Atom.



Wednesday, July 30, 2008

Visual Studio 2008 XAML Intellisense

I noticed the other day that that XAML Intellisense had stopped working in Visual Studio 2008. A quick web search revealed that others had experienced this problem after installing a version of the Windows SDK. I installed the Windows SDK for Windows Server 2008 a couple of weeks ago so it may have been the culprit. A bit more digging revealed that the Windows SDK team have published a workaround for this problem over on their blog. I followed the workaround and XAML Intellisense is now working again.

Click here for the Windows SDK Workaround.


Wednesday, July 23, 2008

Microsoft Distributed Cache

I recently downloaded and had a look at Velocity aka Microsoft Distributed Cache. The team released CTP 1 in early July so it will be interesting to see how Velocity develops over the coming months. The basic idea is to provide a general purpose, distributed, in-memory cache. The cache is provided in the form of a cluster with load balancing behind the scenes. The below diagram helps to explain.


The cache cluster includes a configurable number of cache hosts, each running as a Windows Service. The cluster requires a network share to distribute configuration data including the eviction and expiration policy. Velocity includes a console application to administer the cache.

Velocity doesn't include disk persistence so if the cluster goes down, the cache is reset. You can however attach metadata tags to cache items. This makes it really easy to retrieve groups of objects based on matching metadata.

Working with the cache is pretty straight forward from a .NET application. The Velocity install includes client API with the usual CRUD operations. Here's an example of adding a string to the cache.

using System.Data.Caching;

CacheFactory CacheCluster1 = new CacheFactory();
Cache Cache1 = CacheCluster1.GetCache("Cache1");

Cache1.Add("cachedStringKey1","This string will be stored in cache");

Velocity is targeted at clustered web environments where you can gain some performance benefits by having clustered in-memory state. The Velocity team have also provided a SessionStateStoreProvider that allows you to use it for managing your session state. Here's an article that explains how to configure your ASP.NET application to use Velocity for custom session state. One can only assume that Velocity will become a part of IIS in a future release?

Tuesday, July 15, 2008

Add-Ins for .NET Reflector

There are a number of useful .NET Reflector Add-Ins published up on CodePlex. I tried out BamlViewer today, which allows you to reflect assemblies containing BAML resources and browse the corresponding XAML. Pretty handy if you're working with WPF.


Another Add-In you should know about is Reflexil. This tool allows you to hack the IL inside a loaded assembly and then write the changes to disk.  You can do the same job with a tool called PERWAPI, which is very useful for writing front-end .NET compilers. But Reflexil just makes it so much easier...


Another Add-In I need to checkout is Diff. This tool allows you to compare code differences between assemblies. I wonder if it works for embedded resources? If it does, this little Add-In could be very useful as a sanity check during localization.


Monday, July 14, 2008

.NET 3.0 and mscorcfg.msc

I went searching for the .NET Framework Configuration Tool on my Vista machine today and couldn't find it! The tool used to be at %systemroot%/Microsoft.NET/Framework/<version>/mscorcfg.msc. Anyone got any ideas? I did a bit of digging and some say the tool is now included in the Windows SDK. However, I've installed the Windows Server 2008 SDK and can't find mscorcfg.msc.

Thursday, June 26, 2008


Wednesday, June 25, 2008

Interview Questions for .NET Developers

When was the last time you had to interview a .NET developer? Did you know the right questions? If you had some trouble coming up with a good list, you might want to take a look at Scott Hanselman's blog to read what he thinks great .NET developers should know. The list is a few years old, but hey, so is .NET 2.0.

Click here to read Scott's list.

Technorati Tags:

Monday, June 23, 2008

TIDE 4 JavaScript

I stumbled across a useful browser based JavaScript IDE the other day while trying to jog my memory for Dijkstra's Algorithm. The IDE includes a collection of algorithms for graphs, sorting, graphics, fractals etc. I think it's kinda cool!


Friday, June 13, 2008

Chappelle's Show: Rick James

Chappelle's Show: B-Ball with Prince


Microsoft has released a new SDK for working with Open XML documents. The SDK extends the existing .NET functionality in System.IO.Packaging to provide strongly typed part classes to manipulate Open XML documents. Pretty handy if you're working with with Word and Excel documents.

Click here to download a copy of the Open XML SDK.

I'm currently working through Jeffrey Richter's excellent book Windows via C/C++ and note that he often refers to the Sysinternals tools available on TechNet. Take a few minutes and browse through the list of Sysinternals downloads. ProcessExplorer is on the list and is useful when you need to know what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. Use it as an alternative to the task manager. 

Reading through the latest technet bulletin, I see that you can now access all the Sysinternals tools at and even run the tools by opening a command prompt and executing \\\tools\<toolname>. The idea is that you can access and run the tools from anywhere. Some sysadmins may find this useful when scripting but I don't recommend it for interactive tools like ProcessExplorer. I actually had to hard reset my machine after trying! Honestly, the download is only 1.6 MB!


Thursday, June 5, 2008

Vista SP1 UAC Explained

Click here for an interesting screencast on Vista SP1 user account control. Microsoft have collected user experience stats covering more than 10,000 real world machines and found that after initial setup, 66% of user sessions don't contain UAC prompts. I expect that UAC prompts will become less of an issue in the future as venders update their software to minimise the use of administration permissions. However, if you are an advanced Windows user and want to disable the elevation prompts but still enjoy the protection of UAC, it's really easy to do. Note that this is different to disabling UAC through the security centre.

  1. Open the start menu
  2. Type secpol.msc in the search box
  3. Run secpol.msc by pressing enter
  4. Navigate through the security settings tree to find Local Policies | Security Options
  5. Scroll down through the list of policies to find the User Account Control entries
  6. Select the following policy and open it by pressing enter
    Behaviour of the elevation prompt for administrators in Admin Approval Mode
  7. Choose Prompt for consent from the list of settings
  8. Press the OK button

From now on, Admin elevations will occur without the prompt. Obviously, this only works if you are an Admin user and UAC is enabled in Security Centre. If you're running Vista with UAC disabled, I recommend that you turn it back on and instead disable the prompt.



Note that Secpol.msc is not available on all versions of Windows Vista but the same result can be achieved through the registry.

  1. Open the start menu
  2. Type regedit in the search box
  3. Run regedit.exe by pressing enter
  4. Navigate through the tree to find the following key
  5. Select the following value from the list and open it by pressing enter
  6. Change the value data from 2 to 0 (zero), as shown below
  7. Press the OK button


Wednesday, June 4, 2008

3D Graphics over Terminal Services

Here are a few links for Calista Technologies, one of Microsoft’s recent acquisitions. Calista are working on a visually lossless compression algorithm that enables rich media & 3D graphics on a virtual desktop. Microsoft plans to integrate this technology with Terminal Services to enable DirectX, Vista Aero, WPF applications, full frame rate video and fully synchronized audio.

Click here to read more of the details over on the Terminal Services team blog.
Click here to read more of  the details over on the Virtualization team blog.

Monday, June 2, 2008

WPF Globalization and Localization

If you're starting out with globalization and the Windows Presentation Foundation (WPF), then you're in for a real treat. Microsoft has made it easier than ever before to build globalized software. I suggest you start out by reading this overview on the MSDN. You should be able to figure out the rest with a little trial and error. However, if you're too lazy to read the whole article, I've transcribed some concepts below.

WPF offers several paths to resource localization. You can bind localizable resources in your application to an XML file, store text and images in more traditional resource files, or you can markup your localization preferences in XAML with your user interface. Here is an example of how you can apply a localization comment for the benefit of a translator and attribute content as readable but unmodifiable.

<TextBlock x:Uid="TextBlock_1"
Localization.Attributes="$Content(Readable Unmodifiable)"
"$Content(This is a trademark and should not be translated.)
FontFamily(Font Unreadable Unmodifiable)">
Microsoft Corporation

Localization attributes are important because they give you greater control over your resources. In the example, "Microsoft Corporation" is marked as unmodifiable and therefore cannot be changed in a satellite assembly.

The example also illustrates the use the UID property. These identifiers are a necessary part of the localization API and help to track changes in localized resources. You can add these unique identifiers through msbuild by calling msbuild /t:updateuid Sample.csproj.

With the necessary localization markup in place, you need to perform a few more steps before you can produce satellite assemblies. The first is to add the following XML to your project file:


and then add the following attribute to your assembly info file:

[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

Substitute "en-US" in the above for whatever invariant culture you are using. Note that the fallback location is set to Satellite because the main assembly will not contain any invariant resources. This means that the assembly loader will produce a runtime error if you were to remove all the satellite assemblies.

Building the project will now create a satellite assembly for your invariant culture. Now you need a way to export the resources out of your satellite assembly so that they can be translated. You also need a means to generate new satellite assemblies for your target cultures.

As a step towards helping you on your way, Microsoft have create a sample tool called LocBaml that allows you to parse satellite assemblies to create localizable resources and generate a localized binary. The tool will export the resources out to a CSV file that you can give to a translator. Once the CSV file contains the necessary localizations, you simply pass it to the tool and identify the target locale so it can create the new satellite.

Technorati Tags: ,

PowerCommands for Visual Studio 2008

Visual Studio 2008 is obviously the latest and greatest IDE released from Microsoft and I'm really impressed with the improvements in the text editor, especially the enhancements to intellisense, refactoring and code snippets. However, I occasionally notice that there are one or two missing features.

I recently posted about the refactoring feature that allows you to organise the using directives in your C# code. This feature works great per file, but there is no solution level option that allows you to organise using directives for multiple files.

Another neat feature in the solution explorer allows you to right-click on a project and open the corresponding folder in Windows Explorer. However, there's no option to open a Visual Studio Command Prompt on the project folder. Furthermore, there should be a shell extension that adds Visual Studio Command Prompt Here to Windows Explorer.

And one more thing, why isn't there a Close All menu item when you open the context menu on the document explorer tabstrip? There's a Close and a Close All But This, but no Close All.

Anyway, if you've noticed some of these missing menu options then I suggest you take a look at the latest drop of PowerCommands over on the MSDN Code Gallery. And while you're at it, get yourself a copy of Ghostdoc. Both are highly recommended.

Click here to download a copy of PowerCommands.

Sunday, May 25, 2008

Agile Methodologies

I was recently reminded of an excellent whitepaper by Martin Fowler concerning agile methodologies. I read this whitepaper a few years ago but it's still highly relevant. A key point is that software can be self documenting and describes the design without extensive formal documentation. Iterative development and testing is obviously essential to enable feedback that helps adapt to changing requirements and scope. A formal process is not a substitute for a skilled developer.  It's a very worthwhile read... click here.

As an aside, Martin Fowler will be in Brisbane this week for the JAOO conference. It looks like a pretty cool event and I notice that Joel Pobar will be presenting on .NET language pragmatics. That's some pretty cool company.

Saturday, May 17, 2008

Deep Entity Framework

Visual Studio 2008 SP1 Beta was released in the last week, which is great news for users of ADO.NET since the service pack includes the much anticipated ADO.NET Entity Framework and ADO.NET Services (formerly Astoria). If you're interested in learning more about these technologies, I recommend you start out by visiting to the Data Programmability team blog and the Astoria team blog. Otherwise, Wikipedia has a thorough article on ADO.NET Entity Framework.

However, if you want to take a deep dive into the inner workings of Entity Framework, I highly recommend watching Sam Druker's channel9 screencast. Sam talks about the relationship between object oriented and relational data, and describes the need for inheritance, composition and associations.

Sam also takes the time to differentiate between object data and relational data. He uses the example of calendar data and notes that it is very difficult to use in a purely relational form. He goes on to talk about object databases as a means to work with hierarchical data.

However, Sam also points out that object databases suffer because you get bogged down with encoding and decoding pointers based on object identity. Object oriented databases actually miss the point of data modelling because, through encapsulation, you build walls around your ability to interpret the underlying data. You can't perform any set based operations on OO data so it's very difficult for external applications to interrogate your data in alternative ways.

A final point is that databases typically outlive applications because historical data is fundamental to warehousing and represents valuable intellectual property. Relational databases and set theory offer a means to abstract data from your applications in a way that is not possible with object databases.

Wednesday, May 14, 2008

Sleep & Hibernate Explained

I read an interesting technet article today about the difference between Sleep and Hibernate on Windows Vista computers. I'd never really given it much thought before but the article makes perfect sense. I've distilled the key points if you'd prefer to read on.

Sleep is a low power state that preserves whatever you were doing in memory. A sleeping computer can still wake up at specified times to download and install updates and perform other routine maintenance tasks. After these tasks have finished, the computer will go back to sleep automatically.

Hibernate is a power saving feature that writes your settings and memory content to disk before completely powering down the system. Waking from a state of hibernation takes longer than waking from sleep. This is because your computer needs to load your data and applications from the hard drive back into memory. Hibernate is particularly useful on a laptop when you know you won't be using the computer for an extended period of time and you won't have an opportunity to charge the battery.

Screen savers are apparently antiquated and do not conserve energy. In fact, many of today's sophisticated screen savers use more energy than your computer would use under light conditions. Even when a display goes blank, many screen savers continue to run and consume energy. And some screen savers actually prevent your PC from going to sleep.

Thursday, May 8, 2008

My Thoughts on Armenian Food

After a long day of meetings in the office, some of the guys from work decided to go out for a steak and a beer before going home. Brisbane's a steak and potato kind of town and on a Thursday night, there's no better place than the Breakfast Creek Hotel. They serve a quality steak, though some think it's a little expensive and perhaps mass marketed. Still, the hotel is packed most nights and the quality is hard to deny.

"I've been looking forward to a steak all day", moaned Nick. "I'm so hungry. Still, a good steak is worth the wait and I hear the hotel buys all it's steak from Redmond. They have one of the best beef industries in the world over there."

Most of the guys nodded in agreement. They'd all been eating steaks for years and it's difficult to deny the appeal of an old favourite. What's more, they'd recently sampled some of the new cuts from Redmond and were pretty impressed with the flavour.

Once they arrived at the restaurant, the aroma of juicy steak was almost unbearable. "Dinner time!" they chorused. The hotel was packed and all around they could see the hotel's customers devouring juicy steaks and looking satiated. They found a table, sat down and moments later an enthusiastic waiter appeared with a specials board.

"Good evening gentlemen. Tonight for you we have the special. It's a rare Armenian delicacy, which some consider to be the most delectable food ever conceived. I encourage you all to try it."

"Really, I thought this was a steak restaurant. I've heard of Armenian food before" remarked Geoff, "but know very little about it."

The waiter continued confidently: "Armenian food has a delicate blend of aromas that remind some people of a cedar forest. It's low in fat, has very few calories and no cholesterol. It's also low GI so you won't feel bloated after the meal. It's like nothing you've ever eaten before and I promise that once you've tried it, you won't desire another steak."

"But what's in it?" encouraged John, anxious for some details.

"What ever you like. The remarkable thing about Armenian food is that you get to prepare it yourselves, with the assistance of our head chef. It is very inexpensive though."

"But how do you eat it?" I asked quizzically.

"Ah! You must become ONE with the food! It can only be enjoyed when you eat with your bare hands," replied the waiter.

"Well I'm not too fond of eating with my hands, they'll get dirty. Can't I just use a fork?" asked Geoff.

"Or some chopsticks?" I chimed. "I've just been to Japan, don't you know. I could make a fair meal out of it with chopsticks!"

"No, no, you have it all wrong! Fingers are best," the waiter paused. "I suppose you could use a knife and fork, if you must. We've actually designed a special knife and fork for the likes of you."

"Well, what's wrong with our steak knives and forks? Won't they do?" I asked to no one in particular. "They make short work out of steak," and the diners nodded knowingly.

Now impatient: "You can use anything you like, but you'll be here all night. Our custom implements will get you through the meal much faster. It's really very simple."

By this stage, the diners were starting to look despondent. They all had their hearts set on a steak, but it wasn't forthcoming. The waiter was not service oriented and it was becoming apparent that they would all go hungry.

Then John had an idea: "Perhaps you could let us try a sample."

"I tell you what" replied the waiter, "I'll try a sample for you and tell you how it is."

Suddenly the Armenian chef appeared. "Alright, have you made a decision. If you're having Armenian tonight we better get cracking and place some orders. I don't want to rush you, you're my only customers, but I need to put some plans in place. It's time for action."

With those words it was time for our Boss to get involved: "I don't want to make a rash decision. The guys have already done a lot of thinking about the kind of sauce they'd like with their steak and this new option has given us pause. Perhaps you can give us a few minutes to decide?"

With the waiter and chef out of the picture, the diners were free to talk openly.

"I don't know anything about Armenian food, let alone how to prepare it," I remarked openly. I looked around the restaurant and then said, "Everyone around us is eating steak and they look like they're enjoying it. I hear the steaks come with a quality guarantee. Then there's all the sauces and you can choose your side. Those beer battered fries are my favourite!"

The diners had reached a stalemate. "We're out of time and most of us need to get home. Anyone for some Maccas drive-through?" and with that the Boss led them out of the hotel.

Tuesday, May 6, 2008

Organise C# Usings

Visual Studio 2008 has a neat little feature that organises your C# using directives.  You can remove unused using directives and even sort them! The sorting algorithm even knows to put System namespaces first and follow with custom namespaces.

You can access this function in two different ways: popup the context menu in the code editor and select Organise Usings, or open the main Edit menu and go to the IntelliSense submenu. The only thing missing is option to apply to all files in the solution.


Technorati Tags: ,

Thursday, May 1, 2008

C# 3.0 Language Features

I downloaded the C# Version 3.0 Specification early last year and remember being very impressed with the latest round of language features. Implicit local variable types, extension methods, lambda expressions, object and collection initializers! I couldn't wait to sprinkle that syntactic sugar all over my C# code. However, reality had something different in store and it's only been the last few months that I've used C# 3.0 in anger.

If you're just starting out with C# 3.0, I highly recommend paying a visit to Charlie Calvert's blog and watching the videos of Luca Bolognese and Luke Hoban. Luke's webcast is particularly helpful if you're already familiar with the language features in C# 2.0.

I'm not going to delve far into the C# 3.0 language features in this post. However, I have to draw your attention to the introduction of lambda expressions. I've used anonymous delegates with C# 2.0 for a long time and find them invaluable when using generic collections. However, the anonymous delegate syntax is unreasonably verbose and hampers code readability. Lambda expressions offer a very clean syntax for expressing anonymous delegates in C# 3.0. Here's a quick example:


So I guess I'm a little slow on the uptake of lambda expressions but I'm really happy with the way my code is looking now. I know the Visual Studio IDE helps you out a lot with code completion but why type more than you have to.