Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:27:31+00:00 2026-05-28T21:27:31+00:00

I am processing records by pushing each record through validation stages, then into a

  • 0

I am processing records by pushing each record through validation stages, then into a database. One of the validation steps requires checking if 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 within a command-line harness from Visual Studio (for ease of debugging). So 13/01/2010 gets formatted as 13 January 2010 as per the en-GB setting on my Windows 7 dev machine.

On pushing this onto our test server, a Windows Server 2008 R2, this wrapper class runs within a Window Service (under the LocalSystem account). Exactly the same code, I’ve designed it such that the service is just a thin wrapper. However, after many cycles of debugging, it seems the server is parsing 13/01/2010 as en-US and therefore failing. This is despite the Regional Settings being set to en-GB. (See screenshot)

Regional Settings on server

Note that this is way before it gets to SQL Server so that is not part of this issue.

After fighting with this, I’ve forced the situation by 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);

This now works. My question is, how come the Windows Service, running under Local System assumes en-US and not en-GB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:27:31+00:00Added an answer on May 28, 2026 at 9:27 pm

    Description

    You can set the culture of the current thread to this using Thread.CurrentThread.CurrentCulture.
    This will have effect on all Culture specific things in the current thread.

    Sample

    Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
    

    More Information

    • MSDN – Thread.CurrentCulture Property

    Update

    It seems that your regional settings associated with your account profile are irrelevant when the service is running with the SYSTEM account. The default Culture for a windows service is en-US. There are many discussions on the web. All ending in “set the culture of the CurrentThread”, like my answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Processing an XML file with LINQ to add records into a table in a
I have an inmod for processing one file records and eliminate some unwanted rows
I'm developing an audio processing app using core audio that records sounds through the
I have an aspx page where i am Processing a large number of records
I've got a collection of records to process, and the processing can be parallelized,
I'm processing a record-based text file: so I'm looking for a starting string which
I am reading a text file and processing some records, a relevant sample of
I'm processing 1 million records in my application, which I retrieve from a MySQL
I have a C++ program which does text processing on 40k records. We developed
Lets say there are 100 records in the database for a batch job, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.