Time to stop using non-generic collections

This is one for .NET programmers. Do you use collection classes like ArrayList or HashTable? These are useful in .NET 1.0 and 1.1, but .NET 2.0 and higher has generic collections like List<T> and Dictionary<K,V> which are safer and more efficient. It’s time to tidy up your code, because in Silverlight’s implementation of .NET these non-generic collection types have been removed completely. The BCL Team Blog has the details, together with a handy guide on how to convert your non-generic collections. Of course you can simulate non-generic collections by declaring collections of type Object, so there’s no reason to continue using the old collection types.

Technorati tags: , ,

I broke Vista again

Last time it was Windows Search. This time it was the Start menu. I don’t know what triggered it, but today I noticed something was wrong. When I clicked the Start button, the top level items had all disappeared. There was only a single entry, for All Programs, above which was a large white rectangle whether the other items should have been. After a short while, the Start menu stopped working completely. Clicking the Start button or pressing Ctrl-Esc did nothing at all. I also noticed that the explorer process was using 50% of my CPU time. This probably meant that one of the two available processors in a dual-core box was entirely devoted to some sort of useless loop. On a single processor system Windows might have frozen completely.

I tried a few things. Restarting Windows, of course, and restarting the Explorer process. Didn’t work; same symptoms. I tried the Customize button in Start menu properties, and clicking Use Default Settings. Didn’t work. I tried using Systernals Process Explorer to discover what was causing Explorer to go into a spin. That gave me a stack for the errant thread, but it wasn’t especially illuminating, except that it looked unlikely to be the fault of a third-party context menu handler.

At this point I had to do some other work. Did you know that you can use Task Manager as a crude shell manager?  Just use File – New Task to start an application, and Alt-Tab to switch between applications. Who needs Explorer?

OK, it is just a little clunky. I had another go. Logged on as a different user, and everything worked fine. So it is something in my user profile. Eventually I found the culprit, a registry entry called ProgramsCache at HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage. Somehow this had got corrupted. When I renamed it, Explorer fixed itself. This registry key seems to store your list of frequently used programs. These are the shortcuts that appear above All Programs but below the pinned shortcuts on the Start menu.

Now, how come the Use Default Settings button doesn’t reset this registry key? Still, at least I can get back to work now.