Adding Custom Code to the Reporting Services 2008 R2

Compile the code to generate the TestClass.dll file. To access the code inside this file we need to place this dll  in the default location of the Report Designer which is  \Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies.

To add a reference to the file inside the report perform the following steps:

1. Select Report-> Report Properties from the menu.

2. Select the Reference  tab from the report property window

3. Add a reference to the TestClass.dll by browsing to the location of the default report designer i.e \Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies

4. Add the following code in the expression of the textbox of the tablix.

=TestClass.Class1.Cal(3,4)
This code calls the function defined in the assembly reference. Here you don’t need to use the Code keyword to access the function defined in the Custom assembly. You can also define an instance of the class used in the custom assembly but this is optional as you can access the function using the namespace.classname.functioname inside the expression as shown below:-

5. The output should be as follows

For the custom code to be working after deploying the report you will need to paste the testClass.dll  – i.e the dll file in the bin folder of the reporting services whose default location is

\Program Files\Microsoft SQL Server\Instance_Name\Reporting Services\ReportServer\bin

Finally, just click right on the solution and deploy it on the report server to view it in the production environment.

Pages: 1 2




Related Articles :

5 Responses to “Adding Custom Code to the Reporting Services 2008 R2”

  1. I agree with your main point about the extensibilty features of the custom assembly (CS) but it is not without its drawbacks.

    Interesting example. What happens if the definition of profitability changes? Recompile and redistribution of the DLL?

    Couldn’t/shouldn’t the server backend deliver these business metrics through a Profit level Case statement? Or potentially the business tier of a multi-tiered application?

    Any functionality added to the CS should be carefully scrutinized for its potential benefit/applicability versus its costs.

    CS is a powerful tool but it should be used for functionality not delivered directly by any of the components within the applications framework. For example, automating the printing reports without first having to press the print button.

    Thanks for your efforts and my comments from the cheap seats are from my perspective use or lose them as is seen fit for the situation.

    Cheers

  2. HI,

    NICE ARTICLE.

  3. Question: What is the benefit of doing this instead of perhaps just including a new column returned by the query/sproc/data source that would perform the evaluation there?

    Thanks!

    • Hi Josh,

      Thank you for reply. Well this same functionality can be achieved in various ways like by writing cases in SQL or expressions in SSRS. But the focus of this article was to make users aware that custom code and custom Assembly like features can levarage the SSRS functionality.

      For eg:-Custom code can be used to have a common color for your charts.

      I hope this answers your question.

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |