Deploying a Custom Assembly
To deploy a custom assembly in SQL Server Reporting Services, place the assembly in the application folders of both Report Designer and the report server. By default, custom assemblies are granted Execution permission in Reporting Services. To grant custom assemblies privileges beyond Execute permission, you will need to edit the rssrvpolicy.config configuration file for the report server and the rspreviewpolicy.config configuration file for the Report Designer preview window. Alternatively, you can install your custom assembly in the global assembly cache (GAC).
There are two preview modes for Report Designer: the Preview tab and the pop-up preview window that is launched when your report project is started in DebugLocal mode. The Preview tab executes all report expressions using the FullTrust permission set and does not apply security policy settings. The pop-up preview window is meant to simulate the report server functionality and therefore has a policy configuration file that you or an administrator must modify to use custom assemblies in Report Designer. This pop-up preview also locks the custom assembly. Therefore, you need to close the preview window in order to modify or update your custom assembly code.
To deploy a custom assembly in Reporting Services
Copy your custom assembly from your build location to the report server bin folder or the Report Designer folder. The default location of the bin folder for the report server is %ProgramFiles%\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin. The default location of the Report Designer is %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies.
Placing your custom assembly in the report server bin folder enables you to publish reports that reference your custom assembly, and placing it in the Report Designer folder enables you to run and debug reports that reference your custom assembly in Report Designer.
If you need to grant your custom assembly code permissions beyond the default execute permissions:
Open the appropriate configuration file. The default location of rssrvpolicy.config is %ProgramFiles%\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer. The default location of rspreviewpolicy.config is %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies.
Add a code group for your custom assembly. For more information, see Secure Development (Reporting Services).
Updating Custom Assemblies
At some point, you may need to update a version of a custom assembly that is currently being referenced by several published reports. If that assembly already exists in the bin directory of the report server or Report Designer and the version number of the assembly is incremented or changed in some way, the currently published reports will no longer work properly. You will need to update the version of the assembly that is referenced in the CodeModules element of the report definition and republish the reports. If you know that you will frequently update a custom assembly and your currently published reports need to reference the new assembly, you may want to consider using the same version number across all updates of a particular assembly.
If you do not need your currently published reports to reference the new version of the assembly, you can deploy your custom assembly to the global assembly cache. The global assembly cache can maintain multiple versions of the same assembly, so that your current reports can reference the previous version of your assembly and your newly published reports can reference the updated assembly. Yet another approach would be to set the binding redirect of the report server to force a redirect of all requests for the old assembly to the new assembly. You would need to modify the report server Web.config file and the report server ReportService.exe.config file. The entry might look like the following:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="myAssembly" publicKeyToken="32ab4ba45e0a69a1" culture="neutral" /> <bindingRedirect oldVersion="184.108.40.206" newVersion="220.127.116.11"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>