In one of my current projects, we're using own framework on top of WPF, so it uses in several places something like this:

Margin = (Thickness)thicknessConverter.ConvertFromString(marginAttribute);

And we have installs on hundreds machines and lately, it was not working on two machines, that are next to each other, by throwing something like following:

'30,10,10,10' string cannot be converted to Length.
Source: PresentationFramework; StackTrace:    
at System.Windows.LengthConverter.FromString(String s, CultureInfo cultureInfo)
at System.Windows.ThicknessConverter.FromString(String s, CultureInfo cultureInfo)

First it was - it sure does not look like length, why it fails only on those couple PC's?

Luckily enough, stack trace gave hints right away - it shows CultureInfo parameter, although it was not used from code. I've looked at the source code of ThicknessConverter to find, that it uses TokenizerHelper class, which has following logic:

 internal static char GetNumericListSeparator(IFormatProvider provider)
  char ch = ',';
  NumberFormatInfo instance = NumberFormatInfo.GetInstance(provider);
  if (instance.NumberDecimalSeparator.Length > 0 &&
     (int) ch == (int) instance.NumberDecimalSeparator[0])
    ch = ';';
  return ch;

Which means, that if in Region settings NumberDecimalSeparator is comma (that is the case for Lithuanian region, I'm sure there are more regions like that), it uses semicolon to parse Thickness.

Solution is simple - pass CultureInfo.InvariantCulture as parameter to ConvertFromString method.

Comments wpf  c#