Could not load file or assembly in reporting services

reporting-services

I've created one project for report localization, which consists one class file and three .resx files. In class file, I wrote code which find appropriate .resx file, depending on culture, and read value for given key.

After that, i build up project, copy the .dll into "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies" and change RSPreviewPolicy.config, where I've added one new PermissionSet for Report localization and one CodeGroup tag giving Permission to .dll.

Next step I did was creating report, referencing .dll and write one expression to test localization.

I got following error:

"Failed to load expression host assembly. Details: Could not load file or assembly

I'm obviously missing something, but I can't figure out what?

Does somebody has idea of what to do?

Best Answer

I've found the answer. Problem were permissions for viewing report in Visual Studio Preview mode.

First of all, I was putting dll (with localization class) into next location:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies.

After that, I needed to change RSPreviewPolicy.config file, that exists in same folder location, to apply some security permissions.

In question, I mentioned that I've added one PermisionSet, but now I am sure there is no need for that.

I've just changed two CodeGroup section, which have Execution permission level, to have FullTrust permission level, like this:

<CodeGroup
    class="UnionCodeGroup"
    version="1"
    PermissionSetName="FullTrust"
    Name="Report_Expressions_Default_Permissions"
    Description="This code group grants default permissions for code in report expressions and Code element. ">
    .
    .
    .
</CodeGroup>
<CodeGroup
    class="FirstMatchCodeGroup"
    version="1"
    PermissionSetName="FullTrust"
    Description="This code group grants MyComputer code Execution permission. ">
    .
    .
    .          
</CodeGroup>

Regarding your version of Visual Studio, you must choose appropriate folder path:

  • for VS 2015 --- C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies
  • for VS 2013 --- C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies
  • for VS 2010 --- C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies