Phone (01457) 858877 or email
Reporting Services allows you to write functions in C# or Visual Basic, then reference these as custom assemblies. This blog shows how - and why - you might do this.
Sooner or later (probably sooner) you'll get sick of copying DLL files from your class library to your report server projects, and you'll start wondering why Visual Studio can't copy the files for you automatically. The answer is that it can, if you set up post-build events.
A post-build event is one which is triggered automatically whenever you build a project.
If you're coding custom assemblies in C#, first display the properties of your project:

Right-click on the Properties category of the project in Solution Explorer, and choose to open it.
Now choose to create a post-build event:
These steps are shown below:

The numbered steps to follow to start creating post-build events.
Now build up the commands that you want to run:
Here are the numbered steps:

The steps to follow to create post-build events.
When you've finished, select OK to review your post-build event command line:

These commands are given in full below.
The commands above are:
| Command | What it will do |
|---|---|
| copy /y "$(TargetPath)" "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies" | Copy the DLL built for the project to the Visual Studio report preview folder on the author's computer. |
| copy /y "$(TargetPath)" "C:\Program Files\Microsoft SQL Server\MSRS10_50.SQL2008R2\Reporting Services\ReportServer\bin" | Copy the DLL built for the project to the deployment folder on the author's computer. |
The /y switch means that SSRS will overwrite any files on the target folder.
The procedure for Visual Basic is nearly the same. First display the project's properties:

First right click on the VB class library project, and choose to display its properties.
Choose the Compile tab:

Click on this tab to go to post-build events.
You can now go to the project's post-build events:

Click on the button shown at the bottom right of the dialog box.
From this point, you can continue as for C# post-build events.
There is one thing which catches me out every time!
If you're previewing a report using a custom assembly, you won't be able to build the project (if it's using post-build events to copy the DLL over, that is) until you return to design view for the report.
Reporting Services allows you to write functions in C# or Visual Basic, then reference these as custom assemblies. This blog shows how - and why - you might do this.
Comments on this blog
This blog has 4 comments:
CAN you handle events like printing? If you add a comment giving a summary of what you mean, or a link to a relevant website, I'll certainly consider this. There's always more to learn about SSRS!
Off the top of my head, I'd say it wasn't possible without adding some JavaScript to your report somehow. However, what you could do is create an action for each area, such that when you clicked on the area it transferred to another report, passing in the area id as a parameter. Your client could then print out this second report. Admittedly that's two mouse clicks, not one.
If anyone can improve on this, please add your penn'orth!
You could create a true/false (Boolean) report variable whose expression would be set to the value of a custom assembly function (which could look at the Oracle database). The value of this variable would be calculated once only, when the report first loads. You could then set the visibility of all relevant parts of the report to be the value of this variable.
Not for the faint-hearted - you'll need to learn about custom assemblies and report variables - but it should work OK!
Hi Martin
Great question - rubbish answer coming up! When I'm training on SQL or SSRS, I always emphasise that there is one area I can't help with: security. I too tear my hair out with problems like this. The only thing I can suggest is copying your question to StackExchange or a similar site. Unless any other readers can help?