Why does the following code generate a FormatException?
DateTime.ParseExact("03/01/2012", "dd/MM/yyyy", null);
Perhaps it has something to do with the fact that the code is running under IIS 7.5 Express as a part of an MVC3 site execution logic?
You need to include CultureInfo, for example:
DateTime.ParseExact("03/01/2012", "dd/MM/yyyy", new CultureInfo("en-US"));
Slashes in format string are culture sensitive and if you don't pass in CultureInfo, current culture is used. You can also use CultureInfo.InvariantCulture
and it will work. Jon Skeet provides some detailed explanation here.