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

5

8

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.

Umeko answered 21/9, 2015 at 22:18 Comment(0)
C
2

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.

Ced answered 22/9, 2015 at 3:34 Comment(0)
U
5

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

Umeko answered 22/9, 2015 at 21:36 Comment(1)
IS it same forlder path in case of sql server 2016 & Visual studio 2015?Kenric
M
5

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

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

Marleenmarlen answered 29/3, 2016 at 2:55 Comment(0)
C
2

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.

Ced answered 22/9, 2015 at 3:34 Comment(0)
P
1

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

Pasahow answered 4/5, 2021 at 5:41 Comment(0)
A
0

Adding - In Visual Studio 2022, I had to copy the .dll to:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\PrivateAssemblies\

Angellaangelle answered 10/5 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.