SSRS 2008 R2 Custom DLL takes default CultureInfo always
Hi All, I have written a extended/custom DLL for SSRS 2008 R2 and the code inside it always picks the default values for CultureInfo object. I tried using: 1. CulrureInfo ci = new CulrureInfo(CultureInfo.CurrentCulture.LICD, true); 2. CultureInfo ci = CultureInfo.CurrentCulture; 3. Serializing culture info into byte array and then deserailizing it. All these returns same default values inside CultureInfo object. Please let me know if any one of you faced same/similar problem and found it's solution. Thanks in advance, Anshul Sethi anshul.sethi@hotmail.com
November 3rd, 2011 5:30am

Hi Anshul, Thanks for your post. Please pay attention to your code, the CultureInfo object you referred both are the CurrentCuture which are used in the current thread, that’s why it always picks the default values for CultureInfo object. If you want to create and initialize a specified CultureInfo object which uses the international sort, you can refer to the code snippet below, which shows how to create a CultureInfo object for Spanish (Spain) with the international sort: CultureInfo myCIintl = new CultureInfo("es-ES", false); You can also refer to the below code to change your current thread culture info: Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-FR"); More information about this topic, you can refer to the links below: CultureInfo Class: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx Culture Names and Identifiers: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=VS.95).aspx Thanks, Bill LuPlease remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
November 4th, 2011 12:52am

Thanks Bill for reply :) Actually, culture is "en-US"always however values inside culture info object like negative currency format are being changed. When I serialize culture info into a byte array using Binary Formatter and then de-serialize it, even if negative pattern of currency is set as ‘1’ in regional settings, object after de-serializing shows ‘0’ as negative currency pattern. And, when I run the same serialization de-serialization code in a console app, it shows the correct values according to the changes made. Thanks, Anshul Sethi
November 4th, 2011 1:20am

Hi Anshul, Thanks for your feedback. By default, formats for date, currency, and numbers are determined by the report server language at run time, it’s unnecessary for you to use customer assembly to format the currency value using specified culture info. To override the formatting provided through the report server language, you can set the Language property within the report when you design it. This can be set at the report level or the TextRun level. If you want to vary the formatting based on the language or local settings of the browser or client application, you can set the Language property to an expression that includes the User!Language variable. More information about How to set the Locale for a Report or Text Box, please refer to the link below: http://technet.microsoft.com/en-us/library/ms159642.aspx Thanks, Bill LuPlease remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
November 8th, 2011 5:04am

Hi Bill, As you mentioned above, I am using customer assembly to format the currency value using specified culture info. But the problem is I always get default values in that customer assembly when it is being called by the "ReportingServicesService.exe" or we can say being called from rdl file. I tried setting Language property as User!Language of report (rdlc file) as well as text box inside report, but report still shows the default format i.e. ($12345) whereas I have set -$12345 format in regional setting of my machine. I think this is because custom DLL always returns default values for NegativeCurrencyFormat. Please reply. Thanks, Anshul Sethi
November 8th, 2011 6:15am

Hi Anshul, Thanks for your feedback. Please refer to my last reply, the Reporting services is able to meet your locale and format requirement, why not to remove your customer assembly to have a try.(eg: drag a textbox to the report designer, specify its value to -12312, set its format like below: Thanks, Bill Lu Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
November 10th, 2011 9:08pm

Thanks Bill for reply. This way what you are suggesting will work however it will again always take some constant pattern which I will set in TextBox property. I want my system to take culture info values set by the end user on his local machine. For that I have to pass it from end user's local machine. For that I have to use some custom DLL, or if you can suggest some work arround for it? Thanks, Anshul
November 11th, 2011 1:38am

Hi Anshul, Sorry for delay response. You can take use of the global collection User.Language, which was used to retrive the locale info of the Users. You can right-click the space outside the report body, and press F4 to open Report properties, then scroll down to find the Language property, specify its expression to =User.Language Thanks, Bill LuPlease remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
November 22nd, 2011 4:54am

Thanks for the reply Bill. I got the real problem, actually when a CultureInfo object is serialized, all that is actually stored is Name and UseUserOverride and not other settings like Negative Currency Pattern. It is successfully de-serialized only in an environment where that Name has the same meaning. Reference Link : http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx To solve this, I am appending my useful setting such as Negative Currency Pattern in the serialized string and while de-serialization, I am removing it from string and using it. Thanks, Anshul
November 30th, 2011 9:01am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics