Json.NET dice que "la operación puede desestabilizar el tiempo de ejecución" en .NET 4, pero no en .NET 3.5
Este código:
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
var client = new WebClient();
client.Headers.Add("User-Agent", "Nobody");
var response = client.DownloadString(new Uri("http://www.hanselman.com/smallestdotnet/json.ashx"));
var j = JsonConvert.DeserializeObject<SmallestDotNetThing>(response);
}
public class SmallestDotNetThing
{
public DotNetVersion latestVersion { get; set; }
public List<DotNetVersion> allVersions { get; set; }
public List<DotNetVersion> downloadableVersions { get; set; }
}
public class DotNetVersion
{
public int major { get; set; }
public int minor { get; set; }
public string profile { get; set; }
public int? servicePack { get; set; }
public string url { get; set; }
}
}
}
Lanzará una excepción "la operación puede desestabilizar el tiempo de ejecución" en Deserialize cuando se utiliza la versión .NET 4 de JSON.NET en .NET 4.
Sin embargo, cambiar el objetivo a 3.5 (y cambiar la referencia de JSON.NET a la versión 3.5) funciona muy bien. Estoy usando JSON.NET de NuGet.
¿Pensamientos?