Read time: 9 minutes
An invoice import runs every night.
On my laptop, invoice INV-1001 is 19.99.
On the new server, the same file says it is 1,999. The paid total is a hundred times too big.
I open the code. It is one line: decimal.Parse(parts[1]) . Nothing looks wrong.
The cause: the server has different regional settings, and decimal.Parse quietly uses them.
The short answer
In .NET, methods like decimal.Parse , ToString , ToUpper and string interpolation use the current culture unless you pass one. The current culture comes from the machine or the user account, so the same code gives different results on different machines. For data that programs read and write (files, APIs, databases), pass CultureInfo.InvariantCulture and use ordinal string comparison. Use the user's culture only for text a person reads.
This post shows the bug in a small invoice import, the fix, and three holes I found while testing the fix. All output below comes from .NET SDK 11.0.100 (runtime 11.0.0) on Windows 10.…