Laziale
Laziale

Reputation: 8225

different results running same app locally and remotely - windows app

Something weird is happening with my application. When I am running it locally I am getting the results as they should be, normal decimal number. But when I am running the same application from server, the decimal number is divided by 100. I am using the same code, deploying the same app, and I am wondering why that is happening. Every advice is welcome. Thanks in advance, Laziale

Upvotes: 3

Views: 120

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273179

Obviously you server is running with a different locale.

Whenever you go from string to decimal, the locale (CultureInfo) matters.

For example, ConvertToDecimal("1.00") can give 1 or 100 depending on whether the . is set as the decimal separator or the thousands separator.

To prevent this, always use ConvertToDecimal("1.00", someCulturInfo).

You can only rely on the default when the string is by definition in the users locale.

Upvotes: 3

Related Questions