See loaded assemblies and .Net performance counters with Process Explorer

The latest version of the Windows SysInternals ProcessExplorer now shows the list of loaded assemblies and appdomains as well as a view of the .Net performance counters.

Exploring loaded assemblies of any .Net process

For this to work, you will need Administrator rights, so right-click on processxp.exe and select the Run as administrator entry.

Then select any .Net process, double click to view its details view and select the .Net Assemblies tab.
You will then be treated to the process structure, which is defined this way:

{CLR Version} > {AppDomain} > {Assembly}

For each item you'll see the flags that are set. In this case, I'm running Visual Studio 2010 on a multicore machine so the Concurrent Garbage Collector is enabled. Seems like this app is well-behaved and doesn't load any 2.0 assemblies, and also load the whole 2.0 .Net CLR side-by-side with 4.0 .Net CLR.

You can also see for each assembly where the assembly was loaded from, which can shed light on all your GAC issues.

I'm also using Resharper 5 beta for Visual Studio 2010 and you can see there's a lot of managed assemblies in there. That would explain the huge memory footprint. Can we have One  Assembly To Rule Them All please? 

If you want to create your own appdomain to test

How lazy am I? Very.

Very interesting analysis of the over-use of the term 'Lazy' by El Skeet that exposes the cognitive spaghetti living in most developer's mind (including mine).

On a side note, it is my belief that the true tell-tale sign of a good developer is his laziness.

On that criteria, I am an awesome developer ;)

INotifyPropertyChanged pattern wrapper using LINQ Expressions for Silverlight / MVVM scenarios

Here's a little time-saver when writing  any kind of notifying property, namely MVVM ViewModel classes for Silverlight, or anything implementing the INotifyPropertyChanged interface. The problem is that its implementation pattern is very strict and verbose, hence being a prime candidate for code reuse or copypasta.

INotifyPropertyChange pattern implemented manually

    public class MainPageViewModel : INotifyPropertyChanged
        private bool _isOldAndBusted;
        public bool IsOldAndBusted
            get { return _isOldAndBusted; }
                if (_isOldAndBusted != value)
                    _isOldAndBusted = value;
                    PropertyChanged(this,new PropertyChangedEventArgs("IsOldAndBusted"));

        public event PropertyChangedEventHandler PropertyChanged;

Note that this pattern should be used for each property in a type that supports notification. That's a bit verbose for such a common pattern, and this has a very nasty side-effect, as the string identifying the property in the argument must match the property name under pain of runtime exception. This is going to be an issue with :
  1. Typos : We're all lazy / tired at some point and more often than not "Property" will end-up being typed "Proprety".
  2. Refactoring : Refactoring tools can change the name of a property and even sometimes change string bearing the same name, but the process needs to be checked as some tools will rename the string in totally inrelevant places, thus requiring precious developer attention-span
  3. Me : I'm a typo-prone lazy developer with the attention span of a gerbil and I have a sanctified hatred of copypasta code.
So in order to foolproof notifying properties, as well as save some precious keystrokes that will, over the years, greatly favor the lifespan of your keyboard and fingers, let's find how we can use a typesafe way of extracting a property name, and automagically encapsulate the check/assign/raise pattern of INotifyPropertyChange implementations.

Apple keyboard mappings for Windows

The apple keyboard with numpad is incredibly good.

Reminds me a lot of the Apple 2GS keyboard and it's really a joy to use, to the extent which I ditched my DAS for this one when coding. Here's a pic* ; the keyboard is huge and feels much nicer than the MBP keyboard.

There is one issue though, the insert key is nowhere to be found. Fear not, here are the (sometimes less than obvious) apple keyboard bindings for windows.

In my case: Function+Enter -- well that's going to be easy for CTRL-ALT-Insert in Resharper...

* Stormtrooper included for size

Incredible MVVM talk for SilverLight

This is a very good talk, really illustrates the strength and weaknesses of Silverlight (especially its command binding shortcoming) and mixes the Async Enumerator coroutine trick with the Silverlight Async IO model. N-E-A-T-O !

Installing windows 7 64 on an iMac 27'' or any ATI-powered Mac

So if you don't want to spend 2 hours re re re reinstalling for nothing, here's the scoop:

After rebooting your Mac, the win7 bootloader will show the animated win7 logo, then the screen will turn blank.

That's because the driver for your ATI video card on win7 64 isn't compatible with Mobile Radeon 4xxx, so just pop the win7 cd (or boot in safe mode) and delete the following file:


That's a lot of thanks to the PCWorld writers from me then. Here's the step by step guide to installing win7 64 on an iMac from pcworld.

Cheers then!

Yeah, I got a 27'' i7 Jumbotron and I can't stop drooling. I'm a fanboy, there. At least I can pretend it's for running BSD :D

Quick compiler optimization sample

A quick question from a mate about debugging and code optimization

Here's the code he sent me, and he wanted to know what the compiler would end-up doing in different modes.

using System;

namespace Frankenstein
 internal class Program
  private static bool TestPotimization()
   Random r = new Random();

   string str = null;
   str = "debug";
   str = "!Debug";

   if (r.Next() < 0.5d) return true;
   if (r.Next() < 0.8d) return true;
   return false;

  private static void Main(string[] args)

And here is reflector's output for the release dll:
private static bool TestPotimization()
    Random r = new Random();
    string str = null;
    str = "!Debug";
    return ((r.Next() < 0.5) || (r.Next() < 0.8));

So yes, there is a decent amount of optimization done at compile-time, even before the JIT kicks in at runtime :)