Using Microsoft.ReportingServices.ReportViewerControl.Winforms 150.1449.0, I want to use a calculated padding value on an Image.
In particular, the image is set to resize proportionally to fit and I want to right-align it (which this StackOverflow answer provides a helpful formula for).
The report image is 6.5cm wide and 0.5cm tall and I have parameters that describe the pixel size on disk; plugging this all together it gave me this PaddingLeft formula:
This works perfectly ... as long as the report is run in a locale with a dot as the decimal separator.
When I try running it in a locale using a comma as decimal separator, then the report loads but with no padding. If I have the debugger attached at the time then I see the expression generates a parsing exception when trying to interpret a value containing a comma.
This is not entirely surprising, since
CStr uses the current locale and the report definition internally uses the invariant locale, I guess.
Except: how do I write an expression that will format according to the invariant locale?
'CultureInfo' is not declared. It may be inaccessible due to its protection level.
Value of type 'System.Globalization.CultureInfo' cannot be converted to 'Integer'.
The first error, ok. The second one: wat?
(I think the Real Bug™ is inside ReportViewer itself -- if it's going to use the InvariantCulture to interpret the value then it should use it when calculating the expression too, so that CStr would just work. But that doesn't help me work around this, and there doesn't appear to be any dedicated channel to report bugs to the developers.)