Click here to Skip to main content
14,302,993 members

Using config file for Custom Assembly in Reporting Services (Step by Step)

Rate this:
1.89 (6 votes)
Please Sign up or sign in to vote.
1.89 (6 votes)
15 Jun 2007
A trick to use config file for Custom assembly in reporting services


While going through my last project I learn a lot about custom assembly in reporting services. My current article is very important if you are interested to use config file for custom assembly to connect database. Just for the information, config file provide us facility to use keys in your project rather hardcoded values.



In my last reporting services project it was required to build a generic custom assembly which should use a config file rather hardcoded values. So that we could use this custom assembly on our numerous customer computers without hard coding their database information each time we are going to deploy this assembly.

The major problem to use config file with custom assembly is their "class library" project type. You are all aware that class library assembly is usually called by any other assembly through window base / web base project so whenever you will add config file into the same folder it will not work because to make this custom assembly run under reporting services you have to copy this custom assembly under the "ReportServer/bin" folder in SQL Server installation whether reporting services project location is different so it does not work.

Another way is using a text file as a config file to extract key values but another problem to use text file from custom assembly in reporting services is to set permission first for that text file in your custom assembly which needs Physical Path of that file (again hard coded value), so this trick will not work as well.

Using the code

Steps to solve the problem

Now, there is a very simple solution which allows you to use key values into your custom assembly while you are using reporting services. The trick is to use reporting services "web.config" file to set key values and then use them in our custom assembly.

Steps to add key values in web.config file

1. I assume that you have set your custom assembly permission etc and it is working fine with hard coded values. If you have not done these steps then please go through my another article Creating and Deploying Reporting services using custom assembly (step by step)

2. Find the reporting services installation folder usually C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer and open web.config file.

3. Add key and values under <appSettings> ---here---</appSettings>


<add key="ConnectionString" value="Data source=;initial catalog=PMTest;User Id=sa;Password=sa" />


4. Just for the safe side and to avoid any error, do not forget to add <appSetings> at the end of web.config file before </configuration> tag.

Steps to extract key values from web.config file in your Custom Assembly

1. Use System.Configuration.ConfigurationSettings.AppSettings("ConnectionString") to extract connection string.

Image 1
Ali Faraz
Software Developer
Festival Business Solutions
United Kingdom

Points of Interest

Pleas do not forget to write comments that how can I imporve this article. There may have few things which i have overlook and if you will write comment, i will update my article accordingly and it will be helpful for other readers. Thanks.


Ali Faraz is a software developer in Festival Business Solutions and having 8 years of experience using .net, sql server etc.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

GeneralMy vote of 5 Pin
rahul-techie20-Feb-12 1:47
memberrahul-techie20-Feb-12 1:47 
GeneralReporting Services web.config Pin
DiDee24-Jul-07 21:39
memberDiDee24-Jul-07 21:39 
GeneralRe: Reporting Services web.config Pin
alifaraze25-Jul-07 1:57
memberalifaraze25-Jul-07 1:57 
GeneralRe: Reporting Services web.config Pin
nateastle20-Sep-10 9:53
membernateastle20-Sep-10 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 15 Jun 2007


19 bookmarked