I process the records by clicking each record through the verification steps, and then into the database. One of the verification steps is to check whether certain columns are dates. I did this using DateTime.TryParse (s, out DateTime), assuming that this would use the configured regional settings on the machine on which the process was running. On my local machine, this is a wrapper class running on the command line from Visual Studio (to facilitate debugging). Thus, 01/13/2010 is formatted as January 13, 2010 according to the en-GB setting on my Windows 7 computer.
By clicking this on our test server, Windows Server 2008 R2, this wrapper class runs in the Windows service (under the LocalSystem account). Exactly the same code, I designed it in such a way that the service was just a thin shell. However, after many debugging cycles, it seems that the server is parsing 01/13/2010 as en-US and therefore fails. This is despite the fact that the regional settings are set to en-GB. (See screenshot)

Note that this is the path before it gets to SQL Server, so this is not part of this problem.
After dealing with this, I made the situation using the code below and setting the required format to en-GB.
Culture = CultureInfo.CreateSpecificCulture("en-GB"); DateTimeStyles dateTimeStyles = DateTimeStyles.None; DateTime dt; bool pass = DateTime.TryParse(s,Culture,dateTimeStyles, out dt);
Now it works. My question is: how did it happen that a Windows service running on a local system accepts en-US, not en-GB?
source share