Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly error on adding custom libraries in SSRS reports

I have created a custom library(CodeLibrary) which internally references the dlls Microsoft.TeamFoundation.Client and Microsoft.TeamFoundation.WorkItemTracking.Client.

I added this custom Dll codelibrary.dll to my SSRS report. and the expression of one of the field as

=codelibrary.codefunction.GetValue(1000)  

codefunction is the class and GetValue is the method.

When I preview the report, I get the error "Error while loading code module: 'CodeLibrary,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null'. Could not load file or assembly 'CodeLibrary,Version1.0.0.0, Culture=neutral,PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

I am using VS2013, I have placed the custom library DLL in the path C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies

I have tested the custom library with a WPF application and it works fine.

I am not able to figure out what is causing this error.

like image 945
perplexedDev Avatar asked Sep 21 '15 22:09

perplexedDev


Video Answer


4 Answers

I didnt have to modify rssrvpolicy.config file. I added the custom dll to the following paths and it worked:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin

like image 80
perplexedDev Avatar answered Oct 10 '22 20:10

perplexedDev


In visual studio 2015, I had to copy the dll to:

C:\Program Files (x86)\MSBuild\14.0\Bin

like image 25
UbuRoi Avatar answered Oct 10 '22 21:10

UbuRoi


You should copy your custom library to the ReportServer\Bin folder ex: C:\Program Files\Microsoft SQL Server\MSRS10_50.R2\Reporting Services\ReportServer\bin

Then modify the rssrvpolicy.config in ReportServer folder, find "$CodeGen$" and add the following code

<CodeGroup
    class="UnionCodeGroup"
    version="1"
    PermissionSetName="FullTrust"
    Name="CoDeMagSample"
    Description="CoDe Magazine Sample. ">
   <IMembershipCondition
        class="UrlMembershipCondition"
        version="1"
        Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.R2\Reporting Services\ReportServer\bin\YOURLIBRARY.dll"
/>

After that, Stop and Start Reporting Service from Reporting Service Configuration Manager.

Hope this help.

like image 2
Thang Mai Avatar answered Oct 10 '22 21:10

Thang Mai


Adding - In Visual studio 2019, I copied the dll to: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\SSRS

like image 1
Osnat Avatar answered Oct 10 '22 21:10

Osnat