Adding DataMatrix Symbols to SQL Server Reporting Service 2010 and Above


The manual for DataMatrix Fonts & Encoder 5 includes a chapter on adding datamatrix symbols to SSRS 2008 and prior. The process of adding datamatrix to SSRS 2010 is largely the same, with some differences.

Software Requirements

Adding datamatrix to SSRS reports require install of customer assembly. To develop reports with custom assembly support, you need SQL Server Data Tools (SSDT). The SSDT is included in the SQL Server installation disk, or you can download it free at Microsoft web site by searching SQL Server Data Tools. SSDT is actually a rebranded Visual Studio, withe version correlation as below.

SQL Server 2010Visual Studio 2010
SQL Server 2012Visual Studio 2013
SQL Server 2014Visual Studio 2015

The other report designer software, Report Designer does not have the capability to work with custom assembly.

Adding Custom Assembly to Visual Studio

Remember that you cannot just format the string encoded with barcode font to produce a barcode. Instead, the data string must be encoded into a form called Barcode String first. The encoder function resides on a DLL written in C++. Unfortunately the report cannot call this DLL directly so we provide a wrapper DLL.

For this tutorial the wrapper DLL is called ReportServicePlugin_DataMatrix5.dll, located under C:\Program Files (x86)\Morovia DataMatrix Fonts & Encoder 5. If you are using a different product, refer to the manual for the name and the location of the wrapper.

to install the custom assembly, copy the file to C:\Program Files (x86)\Microsoft Visual Studio [version]\Common7\IDE\PrivateAssemblies directory. Replace [version] with the actual Visual Studio version number, for example, 12.0.

Unlike previous versions, the preview action now requires the custom assembly to be defined in the policy file RSPreviewPolicy.conf. If you do not see this file, you probably look into the wrong directory, or you did not install SSDT.

Open RSPreviewPolicy.config file in a text editor (Run as Administrator), add the following content just before two ending CodeGroup tags:

<CodeGroup class="FirstMatchCodeGroup" 
  Name="ReportServicePlugin_DataMatrix5.dll" Description="ReportServicePlugin_DataMatrix5.dll">
  <IMembershipCondition class="UrlMembershipCondition" version="1"
Url="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\ReportServicePlugin_DataMatrix5.dll" />

Make sure that the file path is correct, and the resulted file is a valid XML file.

Adding Barcode to Report

We recommend that you run SQL Server Data Tools (SSDT) as Administrator. This allows you to deploy the report from SSDT. The Administrator privilege is not required when designing and previewing reports.

Click on Report1.rdlc to switch to report design view. Select Report Properties from Report menu. Click on Reference and add the reference to the custom assembly.

Now right click on the header of the last column and insert a column on the right. Right click on the text box just created, and select Expressions. Change its value to:


You can use the builtin operators and functions to pass more complicated string to the encoder function.

Now Click the Preview tab. You should see the datamatrix symbols appearing in the report.

Deploy Report

You can use Deploy menu from SSDT to deploy the report to the server. However, in order for the server to render the report, you need to add the custom assembly to the server and modify policy file rssrvpolicy.config.

  1. Locate the direcotry of Reporting Server. Usually the directory is like C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer. This directory should have rssrvpolicy.config file and bin subdirectory.

  2. Add the content below to rssrvpolicy.config file, just before two endinging CodeGrouptags:

    <CodeGroup class="FirstMatchCodeGroup" 
      Name="ReportServicePlugin_DataMatrix5.dll" Description="ReportServicePlugin_DataMatrix5.dll">
      <IMembershipCondition class="UrlMembershipCondition" version="1"
    Url="C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\ReportServicePlugin_DataMatrix5.dll" />

    if the policy file is configured correctly, you should be able to view the report corrrectly from the browser.