<p>I've currently got a set of reports with a number of common functions sitting in code blocks within the .rdl files. This obviously presents a maintainability issue and I as wondering if anyone knew a way for these different reports to share a library of common code?</p>

<p>Ideally I'd like to have a .Net Assembly attached to my Reporting Services project, which all of my reports can access and call functions from. This would save the headache of trying to update and redeploy about 100 reports every time a change needs to be made to a common function.</p>

<p>Any suggestions?</p>

[{'answer_id': 71526, 'author': 'jason saldo', 'author_id': 1293, 'author_profile': 'https://Stackoverflow.com/users/1293', 'pm_score': 0, 'selected': False, 'text': '<p>You must deploy to the GAC.\n<a href="http://www.developerdotstar.com/community/node/333" rel="nofollow noreferrer">http://www.developerdotstar.com/community/node/333</a></p>\n'}, {'answer_id': 71533, 'author': 'Darren Gosbell', 'author_id': 11860, 'author_profile': 'https://Stackoverflow.com/users/11860', 'pm_score': 1, 'selected': False, 'text': '<p>The following article lists just about all the different ways of calling .Net code from an SSRS report. <a href="http://technet.microsoft.com/en-us/library/aa902641(SQL.80).aspx" rel="nofollow noreferrer">Extending Microsoft SQL Server 2000 Reporting Services with Custom Code\n</a></p>\n\n<p>If all these reports run against the same server, another option to consider would be to use .Net stored procedures in the database to hold your code.</p>\n'}, {'answer_id': 71638, 'author': 'Tom', 'author_id': 3139, 'author_profile': 'https://Stackoverflow.com/users/3139', 'pm_score': 4, 'selected': True, 'text': '<p>From within Visual Studio in the properties of the report, on the \'References\' tab add the details for the assembly that contains the managed code. This code can be called from expressions within reports using the instance name that is specified.</p>\n\n<p>This assembly can either be stored in the GAC or the PrivateAssemblies directory of Visual Studio, and be deployed to the Report Service \'bin\' directory on the Reporting Services server. For more information refer to <a href="http://support.microsoft.com/kb/920769" rel="noreferrer">How to use custom assemblies or embedded code in Reporting Services</a></p>\n'}, {'answer_id': 74197, 'author': 'Jon Artus', 'author_id': 4019, 'author_profile': 'https://Stackoverflow.com/users/4019', 'pm_score': 1, 'selected': False, 'text': '<p>Many thanks guys, I can now call my assembly from my reports.</p>\n\n<p><strong>Supplementary question:</strong>\nIs there a namespace I can include when I\'m creating my assembly that makes it aware of objects in the report designer such as fields and parameters? It\'d be really great if I could pass, say, a collection of fields in a strongly-typed way to my assembly.</p>\n\n<p><strong>And the answer:</strong> A couple of hours of searching reveals that adding \\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\PrivateAssemblies\\Microsoft.ReportingServices.ProcessingObjectModel.dll as a reference in my assembly allows me to access the various Reporting Services types, such as  Fields and Parameters. Note that in Reporting Services 2008, the <a href="http://msdn.microsoft.com/en-us/library/ms143380.aspx" rel="nofollow noreferrer">namespace changes</a>.  </p>\n'}, {'answer_id': 1546774, 'author': 'Daver', 'author_id': 68095, 'author_profile': 'https://Stackoverflow.com/users/68095', 'pm_score': 2, 'selected': False, 'text': '<p>I had a lot of pain with this so I hope this helps someone.  You can get it from the MSDN article but there are a few points below that I think can help speed someone through this a little faster.</p>\n\n<p>Don\'t forget to add this to your rssrvpolicy.config file:</p>\n\n<pre><code>&lt;CodeGroup class="UnionCodeGroup"\n   version="1"\n   PermissionSetName="FullTrust"\n   Name="MyCodeGroup"\n   Description="Code group for my data processing extension"&gt;\n      &lt;IMembershipCondition class="UrlMembershipCondition"\n         version="1"\n         Url="C:\\pathtocustomassembly\\customassembly.dll"\n       /&gt;\n&lt;/CodeGroup&gt;\n</code></pre>\n\n<p>I forgot to do this and I was hating it for awhile.  </p>\n\n<p>Plus don\'t forget to hit both of the following folders for 2005 with your new dll:  </p>\n\n<pre><code>Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\PrivateAssemblies \nProgram Files\\Microsoft SQL Server\\MSSQL.3\\Reporting Services\\ReportServer\\bin\n</code></pre>\n\n<p>Plus don\'t use log4net with your assembly.  I couldn\'t make it work.  Maybe someone can but not me.</p>\n\n<p>Plus if you mess up like I did you won\'t be able to delete the files until you close Visual Studio.</p>\n\n<p>Plus make your methods shared or static.  It\'s easier.</p>\n\n<p>Create a deployment batch file.  Something like:</p>\n\n<pre><code>@ECHO OFF\nREM   Name: SRSDeploy_Local.bat\nREM\nREM   This batch files copies my custom assembly to my Reporting Services folders.\nREM\nREM   This is the SQL Server 2005 version:\ncopy "C:\\Projects\\Common\\lib\\SCI.Common.SSRSUtils.dll" "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\PrivateAssemblies"\ncopy "C:\\Projects\\Common\\lib\\SCI.Common.SSRSUtils.dll" "C:\\Program Files\\Microsoft SQL Server\\MSSQL.2\\Reporting Services\\ReportServer\\bin"  \n</code></pre>\n\n<p>Finally, build your report before previewing.  </p>\n\n<p>If it builds you\'re likely on your way.  </p>\n\n<p>Except...</p>\n\n<p>You can\'t deploy it to your production report server because you\'ll always get the following error:</p>\n\n<p>Error while loading code module</p>\n\n<p>Which is what I\'m working on right now.</p>\n'}]
['https://Stackoverflow.com/questions/71488', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4019/']