Localization in SSRS Reports


Localization or Internationalization means displaying the content in several languages that can help the user to access the content across the globe. Reports are currently one of the important tools and are used in various fields depending on the requirements of the user. Localization plays a very important role and now it has become a normal requirement of any project. Using localization we can make a single RDL / RDLC file available across multiple locales.

Microsoft has not provided any way to add a resource (resx) file in a report to localize it. But Microsoft provides a way to use an assembly with a report. This will become a workaround to achieve localization in SSRS reports.

To implement this solution we first need to create the assembly that will do the actual localization. This assembly contains a resource file and a class file that has a function that accepts a key name and culture and depending on the culture, the function will localize the value. The class file may have the following definition.

  1. using System;  
  2. using System.Globalization;  
  4. namespace ReportLocalization  
  5. {  
  6.     public static class LocalizedValue  
  7.     {  
  8.         public static string GetString(string name, string cultureInfoName)  
  9.         {  
  10.             string returnString = string.Empty;  
  11.             try  
  12.             {  
  13.                 // Culture formation  
  14.                 CultureInfo ci = new CultureInfo(cultureInfoName);  
  15.                 // Value retrieved from the resource file  
  16.                 returnString = ReportResource.ResourceManager.GetString(name, ci);  
  17.             }  
  18.             catch (Exception ex) { }  
  19.             if (string.IsNullOrEmpty(returnString))  
  20.             {  
  21.                 returnString = name;  
  22.             }  
  23.             return returnString;  
  24.         }  
  25.     }  
  26. }  
Now build the assembly project and get the DLL from the bin folder, either from the debug or release folder. This custom assembly is used within the report.

Create a server report project using SQL Server Business Intelligent Development Studio. Within the report, create a data-source and reports.

Use the following procedure to add this assembly and do report localization.

1. Click on Report >> Report Properties from the menu.

Report Properties

2. Add the custom assembly (DLL) to the report as a reference.

Click on the reference tab and click on the add button. Browse to the assembly and click on the “Ok” button.

Browse the assembly

3. Add the following function Code tab.
  1. Public Function LocalizedValue(name as String, culture as String) as String  
  2.  Try  
  3.     Return ReportLocalization.LocalizedValue.GetString(name,culture)  
  4.  Catch ex As Exception  
  5.     Return ex.Message  
  6.  End Try  
  7. End Function  
function Code

4. To localize a caption, right-click the TextBox and select "Expression". Use the custom code (that is written in the Code tab of the report properties) to get the localized value for any string.

=Code.LocalizedValue("Test", “en-Us”)


When previewing the report, we get an error like "Could not load file or assembly 'assembly name and version information' or one of its dependencies. The system cannot find the file specified."


To resolve this issue, we need to copy our custom assembly in the following folder.
  1. <%Win directory %>:\Program Files (x86)\Microsoft Visual Studio <<Version of visual studio >>\Common7\IDE\PrivateAssemblies  
The is an example of our Windows directory is C:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies

Upload report on report server

When we use a server report, all the reports need to deploy to the report server. When our report contains a custom assembly, we might get an error like "Error while loading code module....".

report server

Solution: to resolve this issue, we need to copy our custom assembly to the following path:
  1. <%Win directory Program Files\Microsoft SQL Server\MSRS11.<<version>> \Reporting Services\ReportServer\bin  
The is an example of our Windows directory is C:

C:\ Program Files\Microsoft SQL Server\MSRS11.SQLEXPRESS\Reporting Services\ReportServer\bin

Most Common problem you may encounter

The most common problem using this approach is that when adding the new resource (resx) file it will not be reflected in the report. The reason for this is the custom assembly (DLL) is not updated in the following paths.
  1. Program Files\10.0\Common7\IDE\PrivateAssemblies  
  2. Program Files\Microsoft SQL Server\ MSRS11.SQLEXPRESS\Reporting Services\ReportServer\bin  
It's done!

The SSRS Report is now localized.

I hope this will help you.

Similar Articles