Mirality avatar image
0 Votes"
Mirality asked JackJJun-MSFT commented

BUG: RDLC Winforms evaluates style expressions as CurrentCulture despite evaluating the result as InvariantCulture

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.)

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

On a related note, the DefaultReportServerSpecificCulture related bug hasn't been fixed yet either.

0 Votes 0 ·

@Mirality , Currently I could not full understand your question. Based on your description, I don't see what is related to the nuget-package Microsoft.ReportingServices.ReportViewerControl.Winforms. Also, Please provide all the code related to =Round(6.5-0.5*CDbl(Parameters!LogoWidth.Value)/Parameters!LogoHeight.Value,2).ToString(CultureInfo.InvariantCulture)&"cm", It will be better for us to analyze your problem.

0 Votes 0 ·

0 Answers