user2029505
user2029505

Reputation: 529

C# program stops working after the language setting in control panel is changed (say, from English to German)

I have a software developed in C#, which is a pure sentefic application. Howver the German users found this software stopped working from time to time, when it is installed on German computers. The temporary solution is to change the Language setting in the control panel, and it works fine after we change the language setting from German to English. This is just a kind of engineering sofware, and the software have nothing relalted to the German or English language. Also, as suggested from other posts in msdn, I have checked the "InitializeComponent()" in the source does several times. There are not strange codes in the "InitializeComponent()" function.

Upvotes: 0

Views: 217

Answers (2)

Alex Filipovici
Alex Filipovici

Reputation: 32571

If you are using .NET Framework 4.5, you might be interested to read about the CultureInfo.DefaultThreadCurrentCulture Property.

In the .NET Framework 4 and previous versions, by default, the culture of all threads is set to the Windows system culture. For applications whose current culture differs from the default system culture, this behavior is often undesirable.

The examples and their explanations on the page could be quite helpful for your issue.

Also, as a side note, try{...}catch{...} blocks are always welcome.

Upvotes: 0

Paul Ruane
Paul Ruane

Reputation: 38610

When you change locale, you change the meaning of ',' (comma) and '.' (full-stop) when used in numbers. Could it be that you are trying to parse text containing these characters into numbers?

Does your program attempt to initialize numeric fields with formatted numbers, perhaps?

You need to make sure that your code is sensitive to the user's culture when parsing and formatting text. You also need to make sure you use a consistent culture (e.g. the InvariantCulture) when reading data stored to file or sent over a network.

Upvotes: 2

Related Questions