reporting-servicesssrs-2008-r2

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.


Solution

  • 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.