Category Archives : Programming

This category is designed for entries which relate to software development

Preparing for ASP.NET vNext and Visual Studio 2015

Happy Thanksgiving to folks in the USA.

I’ve finally taken the plunge and decided to get stuck into the recently released Release Candidate (RC) of ASP.NET 5.  Prior to today, I’d stuck with the RTM version of Visual Studio 2015 which insulated me from some of the changes which are on the horizon.

A few months ago, I’d managed to put together a working (live) solution using VS 2015 and the new Web Projects, and you can see it here at

Whilst this was handy experience, it barely prepared me for the massive changes to the development environment which ASP.NET 5 RC requires.  This article contains my experiences in getting a Web API project compiled and run when consuming ASP.NET 5 RC packages.

Git Support

Whether you use Github, Team Foundation Server Source Control or no source control, you’ll want Git support in your dev environment anyway.  A lot of PowerShell scripts and commands pull and clone from Git repositories, and command line integration, IMHO is essential.  If you haven’t installed Git support with Visual Studio 2015, now’s the time to do so.

Install Git/GitHub support when you install Visual Studio 2015 (or modify your install)


Also you can download Git tools for Windows from and support for Git in PowerShell here:

Speaking of PowerShell….

Preparing PowerShell

Enable PowerShell script execution.  You’ll probably be working with PowerShell more than you have in the past, even if you aren’t writing the script.  You’ll certainly be using PowerShell commands, at a minimum inside the Package Manager Console inside VS 2015.

Open a PowerShell console as Administrator, then: Set-ExecutionPolicy Unrestricted

If you get the following error when loading the Package Manager Console inside Visual Studio 2015:

“”Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Unrestricted. Type “Get-ExecutionPolicy -List” to view your execution policy settings. For more information please see “Get-Help Set-ExecutionPolicy”.”””

Here’s my PowerShell Execution Policy on a Workgroup-based computer:


..and on a Domain-joined machine with a Group Policy Object applied:


It’s likely caused by a Group Policy Object (GPO) which is setting a domain-policy on PowerShell restrictions.  Even if you modify and update group policy, this error condition may persist.  Based on an article here:

A registry hack will get you past this annoying issue:

Windows Registry Editor Version 5.00



Working with DNX, DNU and DNVM

To manage different versions of the .NET Runtime environments, you’ll need to get familiar with dnx (Microsoft .NET Execution environment), dnu (.NET Development Utility) and dnvm (.NET Version Manager).  Screenshots below.  You should be able to execute them from the Visual Studio 2015 Command Line Tool:








If you get the message:

“’dnx’ is not recognized as an internal or external command, operable program or batch file.”

You can fix this issue by running the following command:dnvm use default –p

which will persist the changes to the environment variable for the current user.


On another machine, I was warned about a deprecated environment variable:


Which might beg the question….

What are KRE, KVM, KPM?

In short, KRE/KVM and KPM are management bits for ASP.NET 5.  K-bits were named to DNX/DNVM.  I’m Including this info in case it leads you to this article.

From the link above:

K has three components:

  1. KRE – K Runtime Environment is the code required to bootstrap and run an ASP.NET vNext application. This includes things like the compilation system, SDK tools, and the native CLR hosts.
  2. KVM – K Version Manager is for updating and installing different versions of KRE. KVM is also used to set default KRE version.
  3. KPM – K Package Manager manages packages needed by applications to run. Packages in this context are NuGet packages.

Microsoft ASP.NET and Web Tools 2015 (RC) – Visual Studio 2015

Lastly, before you get too excited, there’s a couple of hundred megabytes of updates you’ll need to the supporting tooling for the RC (RTM differs too much, some important things were renamed since then).

The latest version, naturally, requires updated tooling.  If you only have Visual Studio 2015 RTM, then prepare for some fun.  You can download the RC bits here:

Which leads me to installing all of the following on my Development machine:



The net result is that when I now open Visual Studio 2015, and I create a new project – I select .NET Framework 4.6 and when I create a new ASP.NET Web project, the options include:




Here’s some infuriating error messages you might stumble across in trying to compile a simple Web API…..

“DNX 4.5.1 error NU1002: The dependency <Assembly> in project <Project> does not support framework DNX,Version=v4.5.1.” e.g.

“DNX 4.5.1 error NU1002: The dependency System.Runtime 4.0.0 in project Asp5Api does not support framework DNX,Version=v4.5.1.”


System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.DNX.PackageManager’ or one of its dependencies. The system cannot find the file specified.

Means you probably haven’t installed the latest Web Tools.  The PackageManager assembly apparently has been renamed, and is reflected in the later (post-RTM) versions.

High Availability: MassTransit 2.x with Clustered MSMQ – Part 1

So this article isn’t going to be for everyone, however I suspect it will be somewhat appealing for anyone who is looking at Windows Server 2012 R2’s Failover Clustering capability. 


I’m going to write this in a series of posts, as I think there’s also some merit in looking at diagnostic approaches to finding out what the heck is going wrong with a Failover Cluster, rather than focusing on an ideal end state in isolation.

If you’re not interested in the MassTransit parts, skip this introduction and check out Part 2 (coming soon!) which will focus on Clustered MSMQ roles and diagnosis.


MassTransit: In a Nutshell

We’re taking a view of Failover Clustering from the point of view of MassTransit, which is an open source implementation of a lightweight message queue-backed Service Bus (of sorts).  Here’s the official blurb from the GitHub page:

MassTransit is a free, open-source distributed application framework for .NET. MassTransit makes it easy to create applications and services that leverage message-based, loosely-coupled asynchronous communication for higher availability, reliabililty, and scalability.

Some documentation is also available here.

What are we focusing on?

Well, MassTransit, from version 3.x onwards, only supports RabbitMQ and the Azure Service Bus.  As we had initiated implementation in late 2014 with version 2, we flaunted the abandonment of MSMQ and boldly decided to use it anyway; mainly because it is an OOB first class service as standard with Windows Server 2012 R2 (and earlier versions).  So this article won’t feature RabbitMQ or Azure Service Bus, but I might tackle that topic at a later time.

To eliminate a ton of extremely complex code, support for MSMQ was completely ripped out [1]

Therefore, this series of articles pertains only to MassTransit version 2.x and MSMQ.

We’re also using subscriptions, which means we are using the MassTransit subscriptions queue, and message consumers & subscribers register with a runtime service before interacting with the message bus.  This is important to note, because the objective of using a clustered queue is to mitigate service outages by shifting the active queue.

How does MassTransit work, in basic terms?

We’re working with two categories of (.NET) application; message publishers and message consumers.  An application can do one or both, in other words you can publish, subscribe or publish and subscribe.


There’s one caveat: both need to use a local MSMQ, which is used for two reasons essentially – a local staging location for retrying the publishing of messages and also to hold unprocessed and processed messages for consumers (in case the consumer is offline but has a persistent subscription).  There’s also an error queue which messages will land in if they are unable to be successfully processed.

What is your High Availability goal?

Essentially, we want to have the subscription queue highly available.  In the event of an unplanned outage, the queue will move to the next available node in the cluster.  The clustered MSMQ role also has a dedicated network name & IP address which means that it acts as a central address point – no matter which machine acts as the active host – i.e. no need for publishers or subscribers to be aware of the cluster itself.

Since the majority of message consumers in the design also reside on the same server, the act of failing over the HA queue would also failover the message consumers too. 

This approach doesn’t rule out scaling horizontally at a later stage if we need to, there’s a plethora of options which can be made available, including some home brew options from MassTransit itself in the form of something called the Distributor.

Solution Outline

So if you look at my approach, the intention is to cluster two or more Windows Server hosts, and then stick a bunch of Windows Services on each node in the cluster, making them Cluster Resources. The simplistic model is to have the services started only on the active node.

Here’s an illustration of the target solution, with a two node Failover Cluster:

Conceptual Design

The MassTransit Runtime Service manages message subscriptions, from the clustered MSMQ role.  Now none of this really should make sense until you see the deployment in context.  The following is a sample diagram of a typical DMZ/LAN architecture:



So that’s the essential scope of my MassTransit HA deployment.  What will come in the next article is a closer inspection of how High Availability failover will function, and the mechanics behind it.

If you were looking for Clustered MSMQ guidance, Part 2 is for you!

Visual Studio 2015 – Using a Product Key 3


Continuing from the experience with Visual Studio 2013, the next edition – Visual Studio 2015 – was officially released to MSDN subscribers early this morning.  This edition follows the trend established in the previous edition of providing two channels of licensing – by using a Microsoft Account or by supplying a product key.

Get a Product Key

You’ll need to have an MSDN Subscription which matches the version of Visual Studio you are using.  Authenticate to MSDN Subscriptions and go to the Subscriber Downloads section. 


Here you’ll see a tab for “My Product Keys”.  In the list of keys there should be static activation keys for your account.  Find and copy out the product key for your version of Visual Studio 2015 (e.g. Enterprise, Professional, Test Professional).


  • If you don’t have a Product Key listed, as with Visual Studio 2013 it’s likely tied to the type of MSDN Subscription you have – whether you have assigned a perpetual license of not.  Whether or not Visual Studio carries a Product Key/perpetual license seems to depend on the type of MSDN subscription.
  • If you don’t have an MSDN subscription, but have instead purchased a retail copy of Visual Studio 2015 when it becomes available, there should be a Product Key with the product.  A boxed product should have a Product Key on the media (or box) and a soft copy should have a key associated with it somehow (maybe it is mailed to you?).

Install Visual Studio 2015

Once you have acquired a Product Key, the next step is to install Visual Studio 2015.  I’ve chosen to evaluate Visual Studio 2015 Enterprise edition, which replaces Premium and Ultimate editions (they have been merged into a single SKU).

image  image image

There’s some different options in this new edition (when using a custom install), the options I selected to install will absorb over 24 GB of hard drive space.  Probably best you avoid installing VS 2015 o a netbook!  If you want to minimise the install vector, unselecting the Cross Platform Mobile Development saves a lot of space.

Registering Visual Studio 2015

Once the installation completes, you’ll be able to launch the Visual Studio 2015 IDE.  You’ll be taken through the usual “first time user” wizard, which establishes your development and UI preferences.  You can skip logging in with a Microsoft account by choosing “Not now..”.

image  image

Once the IDE loads, you can select “Register Product” from the Help menu:

image  image

Once the registration dialog appears, use the “License with a Product Key” option, and enter your Product Key with the popup window.

image   image

Note: you don’t have to be online for the process to complete, so it looks like a good option for offline installs.


None!  The normalised CamelCase menus are back by default.