Custom Assembly in SQL Server Reporting Services (SQL Server 2008)

As we discussed in the last article, sometimes it may be necessary to add functionality which is too complicated for embedded code to handle or there could be some functionality that is to be used in various reports. Since Embedded code can only be used in the report where you have declared, to make the functionality available in multiple reports, you can use custom assembly.

Let us continue with the previous example where depending upon the count, we will specify the font color. We will take the value of count as a parameter and return the font color.

Let us create a class library with following code:


namespace CustomAssembly
public class CustomClass
public string ReturnColorName(Int16 count)
string returnValue = string.Empty;

if (count == 1)
returnValue = "Red";
else if (count <= 10)
returnValue = "Yellow";
returnValue = "Green";

return returnValue;


Namespace CustomAssembly
Public Class CustomClass
Public Function ReturnColorName(ByVal count As Int16) As String
returnValue As String = String.Empty

If count = 1 Then
returnValue = "Red"
ElseIf count <= 10 Then
returnValue = "Yellow"
returnValue = "Green"
End If

End Function
End Class
End Namespace

Build the assembly. Go to Report, Report Properties and Select References tab


We need not give the instance name if we are working with static method. In this case we are working with an instance method.

Now we need to copy the assembly created in the folder :

<drive name>\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies

when we are working with the designer.

To make it available for deployed reports, we would need to copy it in the following folder:

<drive name>\Program Files\Microsoft SQL Server\MSRS10.SQL08\Reporting Services\ReportServer\bin

Now specify following expression for font color

=Code.MyClass.ReturnColorName(Fields!<count field name>.Value)
And you are good to go!


Anonymous said...


Just for those using Visual Studio 2010... Before namespace in SSRS you will have to add root namespace which you can find in solution properties in VS2010. Took me a while to work it out!


Andy Owl said...


There's also a full tutorial on custom asssemblies in SSSS at, if that helps your readers.