Failed to grant permission to execute error and Zen Barcode for SSRS 2016 Reporting Services

Copy assemblies into the correct reporting services folder

When migrating to a new SQL server the barcodes were causing an issue, firstly because we lacked the barcode assemblies in the reporting services bin folder for the new version of Reporting Services that came with SQL server 2016.

Finding the dlls still in the path for the old Reporting Services server service, they were copied to new active location as shown:

Copy the Zen.Barcode.* files into the bin directory of currently active reporting services server

Permissions Error

After moving the required .dll into the correct location for this server, we then got a permission error.

Failed to load expression host assembly. Details: Could not load file or assembly 'Zen.Barcode.SSRS, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b5ae55aa76d2d9de' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418) (rsErrorLoadingExprHostAssembly)

rssrvpolicy.confg

Setting permissions to the assembly for reporting services is a matter of adding some grants to the policy file. Insert the following block after the last tag in that file.

"Program Files\\Microsoft SQL Server\\MSRS13.MSSQLSERVER\\Reporting Services\\ReportServer\\rssrvpolicy.config"

<CodeGroup class="UnionCodeGroup" Name="BarcodeControl" version="1" PermissionSetName="FullTrust" Description="This code group grants Zen.Barcode.SSRS.dll FullTrust permission."> 
    <IMembershipCondition class="UrlMembershipCondition" version="1"
        Url="C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\Zen.Barcode.SSRS.dll"/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" Name="BarcodeControl2" version="1" PermissionSetName="FullTrust" Description="This code group grants Zen.Barcode.SSRS.dll FullTrust permission."> 
    <IMembershipCondition class="UrlMembershipCondition" version="1"
        Url="C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\Zen.Barcode.Core.dll"/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" Name="BarcodeControl3" version="1" PermissionSetName="FullTrust" Description="This code group grants Zen.Barcode.SSRS.dll FullTrust permission."> 
    <IMembershipCondition class="UrlMembershipCondition" version="1"
        Url="C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\Zen.Barcode.Design.dll"/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" Name="BarcodeControl4" version="1" PermissionSetName="FullTrust" Description="This code group grants Zen.Barcode.SSRS.dll FullTrust permission."> 
    <IMembershipCondition class="UrlMembershipCondition" version="1"
        Url="C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\Zen.Barcode.SSRS.Design.dll"/>
</CodeGroup>

At this point we were able to start using the barcodes again in reporting services.

Reminder on setting up barcode in a report

Create references in the Report>>Properties for the .dll files as shown

Zen.Barcode SSRS references

In the code tab of the report properties set a function that will return an image binary  that will be used as an expression for the image source in the report.

2019-02-27_09-45-13

Drop an image into the report that will be the barcode and set the expression for the image MIME type as shown.
2019-02-27_09-43-33

Example of the expression for the image, in this example, using the value of another field as the source for generating the barcode.
2019-02-27_09-43-20

If you found this helpful- then do comment, it helps motivate me to document more of these kind of things.

Reference: https://www.barcoderesource.com/configurereportingservices.shtml