All posts by Gigi

Meet .NET Native

.NET Native is an upcoming technology that can make .NET applications run with the performance of C++ applications. This preview technology is currently limited to Windows Store and Windows Phone 8 apps and can only be used on Windows 8.1 while targeting x64 or ARM architectures.

Normally, applications are compiled into MSIL and then JIT-compiled into native code at runtime. If .NET Native is enabled, then an additional step takes place which compiles the MSIL into native code through the Visual C++ optimizer.

You can download .NET Native from the .NET Native homepage; after that, enabling .NET Native compilation is simply a matter of ticking the “Compile with .NET Native tool chain” checkbox in the project’s Build properties.

As I mentioned earlier, .NET Native only applies to a very limited set of application types. Let’s hope that in future its benefits might be extended to a wider range of applications (e.g. desktop applications).

If you want to know more, check out Shawn Farkas’ 4-minute intro, or the longer Inside .NET Native video.

How Learning to Play an Instrument Makes You a Better Professional

I briefly mentioned the importance of experience in my recent article, “On Military Intelligence“. There are many skills which you can only learn in one specific way: by doing it a lot. Such skills include reading, writing, driving, art, programming, and music. That’s why “practice makes perfect”.

Music is a daily commitment, requiring lots of practice in order to learn and master the theory, practice, techniques and styles. One could even go as far as to say that it quickens the mind, as the arrangement of notes into various scales and patterns is almost mathematical in nature, and one learns to reason about them.

However, beyond the music itself, learning to play an instrument can help you develop certain characteristics that are particularly important at work. Let’s see what these are.


Music is like software: if you’re going to work on it, then it’s worth taking the time to do it properly, as I’ve written in my earlier article, “On Goal-Orientedness and Mediocrity“. Attempting to rush something will only result in poor quality. While such deficiency may go unnoticed for several months in software, it is much easier to realise when a tune you’re playing doesn’t sound right.

Music gives you the patience to take the time to do things the right way.


Playing in front of other people, even if it’s just the teacher, can be intimidating. Aside from any possible confidence issues that one might have, there is the fear that doing something wrong in front of others will make you look stupid.

And that’s a good thing, because this pressure causes you to prepare well for when you need to do something in front of people. The next time you give a presentation at work, or you lead a meeting, you know you’d better know what you’re talking about.

And at the same time, playing regularly in front of people and getting used to the fact that you’re doing it right has the effect of boosting your self-confidence and helps you overcome any fear of audiences.


When you’re a 27-year-old who’s been playing for six months, and you’re in the same room with 12-year-olds who have been playing for six years, that’s a pretty humbling experience. They’re kids, so you should know more than them, right?

It’s also possible that there are people with less experience, but who are much better than you are. The same can happen at work – someone younger might have a lot more talent than you.

You can be arrogant, and perceive such people as a threat. Or you can accept the reality that they have a lot to offer, and try to learn from them, and in doing so benefit from their experience and become better at what you do.

The Windows 10 window style you never see

I am currently installing the Visual Studio 2015 Preview on the machine where I have the Windows 10 Preview installed, and since it’s an old machine with just 1GB RAM, Windows started hanging at times. The screenshot below shows what the installer looked like while it was hanging:


See that tiny box towards the top of the screenshot? I guess that’s what windows actually look like before the clunky window style we’re familiar with gets rendered over it.

It’s nothing new – I’ve written before about legacy window styles appearing in Windows XP and this seems to continue that trend. The window style above has a very Windows 2000 feel to it, and I personally prefer it over what we have today in Windows 8+.

Dependency Injection in WCF Services with Ninject

Implementing dependency injection in a WCF service can be a little tricky since you don’t directly control the lifetime of the class that implements the interface. However, it is a simple matter to get it working with Ninject. This article by Aaron Stannard and this article by Tony Sneed were pretty useful to find the right direction; however they are a little out of date and the APIs have changed a little.

Part 1: Setting up a test scenario

Create a new WCF Service Application.


Create a new interface called IRepository:

    public interface IRepository


Create a new class called Repository which implements the IRepository interface:

    public class Repository : IRepository


In your Service1 class, add a constructor that depends on IRepository:

    public class Service1 : IService1
        private IRepository repository;

        public Service1(IRepository repository)
            this.repository = repository;

        public string GetData(int value)
            return string.Format("You entered: {0}", value);

        public CompositeType GetDataUsingDataContract(CompositeType composite)
            if (composite == null)
                throw new ArgumentNullException("composite");
            if (composite.BoolValue)
                composite.StringValue += "Suffix";
            return composite;

Click on Service1.svc in Solution Explorer, and then press F5 to debug the application. Making sure that Service1.svc is focused, causes the WCF Test Client to be launched when you press F5.

Notice the error you get because of the constructor we just added:


Part 2: Setting up Ninject

Stop debugging. Right-click on your solution in Solution Explorer, and select “Manage NuGet Packages for Solution…“. Search Online for “ninject wcf“, and install Ninject.Extensions.Wcf (note that this also installs other related packages that you need):


With that done, right click on Service1.svc and select “View Markup“:


Configure the service to use the Ninject ServiceHost Factory by adding the line highlighted below:

<%@ ServiceHost Language="C#"

Next, add a new Global Application Class, either via the context menu shown below, or via Add -> New Item… under Web templates, and name it Global.asax:


The Global class you just created must inherit from NinjectHttpApplication, and needs to have a new CreateKernel() method to create the IoC container and configure any types (in this case our IRepository):

// ...

using Ninject;
using Ninject.Web.Common;

namespace WcfDependencyInjectionNinject
    public class Global : NinjectHttpApplication
        protected override IKernel CreateKernel()
            var kernel = new StandardKernel();
            return kernel;

// ...

Part 3: Testing

That’s all you need! Once again, select Service1.svc in Solution Explorer, and hit F5 to run the WCF Test Client.


As you can see, the WCF Test Client now connects to the service without any problems. You can put a breakpoint to see how a Repository instance is really being passed into the service’s constructor, and you can invoke service methods via the WCF Test Client.

Windows 10: Switching between Start Menu and Start Screen

Windows 10 Technical Preview brings back the Start Menu (as I wrote in my recent 20-minute review), which replaces the tiled Start Screen that was prevalent in Windows 8 and 8.1.

However, for those who actually liked the Start Screen, you can bring it back by changing a simple setting. First, bring up the Taskbar and Start Menu Properties, either by right-clicking on the taskbar and selecting Properties, or by typing “Navigation” in the Start Menu’s search bar and selecting either of the options provided:


Switch to the Start Menu tab, and then turn off the “Use the Start menu instead of the Start screen” option:


You will then be prompted to sign out and sign back in again to effect the change:


Once you do this, you still go directly into the desktop. But when you click on the Start button or press the Windows key on your keyboard, you are taken to the Start Screen instead of the Start Menu: