WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 482 reviews for our classroom and online training
SSRS custom assemblies using C# or VB
Part one of a six-part series of blogs

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.

  1. Creating Custom Assemblies in Reporting Services (this blog)
  2. Creating a Project, Class and Function in VB or C#
  3. Create and Deploy the Code DLL
  4. Referencing and Using Custom Assemblies in Reports
  5. Post-Build Events to Help Deployment
  6. Debugging Custom Assemblies

Posted by Andy Brown on 03 August 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Creating Custom Assemblies in Reporting Services

In SQL Server Reporting Services (SSRS) you have access to a whole range of built-in functions.  However, to release the full power of SSRS you'll need to create custom assemblies.  This rather long blog will explain how - and why - you might do this!

Our Example - a Proper Case Text Function

Suppose that you frequently want to capitalise a word.  SSRS includes functions to convert text to upper and lower case, but nothing to capitalise a word:

The text functions

The LCase and UCase functions convert text to lower and upper case, but neither capitalises a word.


You could get round this by embedding a VB function in a report, looking something like this:

Embedded code function

Embedded code is hard to read, limited to a single report and VB-specific.

However, the best solution is to create a function in VB (or C#), compile this into something called a DLL file and then reference this within your report.  This is called a custom assembly.

Advantages of Custom Assemblies

There are a fair few hoops to jump through to create a custom assembly; why would you need one?  Here are some reasons:

Advantages Notes
Portability Code that you embed within one report is obviously not available for other reports to use, whereas you can reference a custom assembly from any report.
Error-checking When you type code into the Report Properties dialog box there's no way of knowing whether you've made any syntactical mistakes until you try to run it, whereas custom assemblies provide full Intellisense and code formatting.
Languages You can write custom assemblies in either VB or C#.
Speed It's not usually a big issue, but code in a custom assembly can be pre-compiled, and so will run more quickly.
Debugging You can debug code using a custom assembly.

Following the Rest of this Blog

To create a custom assembly you will need to do the following:

  1. Create a project, class and function.
  2. Build, deploy and reference your DLL.
  3. Use the custom assembly within a report.
  4. Deploy your project (perhaps automatically, using post-build events).
  5. Learn how to debug a custom assembly.

Let's begin by creating a project, class and function in Visual Studio.

This blog assumes that you already know basic programming in either VB or C# (examples are given for both languages).

This blog has 0 threads Add post