Set Culture Info - Windows Service

  • Thread starter Thread starter Andreas Michaelou
  • Start date Start date
A

Andreas Michaelou

From a windows service I am calling a method from an assembly that
does some processing and stores some records in an SQL database.

I am using the dot(.) as my decimal point. When I call this method it
considers the dot(.) as the grouping symbol.

When I call the same method from a web application where I have the
default culture as en-GB it works fine.

I was wondering if this is a culture problem, and if yes how can I set
the culture in windows service

The service runs under Win2k SP4
 
Hey Andreas,

Use the following line to set the culture of the current thread to en-GB:

System.Threading.Thread.CurrentThread.CurrentCulture = new
CultureInfo("en-GB");

You can also use the invariant culture which might be better for a service:

System.Threading.Thread.CurrentThread.CurrentCulture =
CultureInfo.InvariantCulture;

HTH, Jakob.
 
Back
Top