.NET 4 version of #170