app.config for DLL

  • Thread starter Thread starter Bucky
  • Start date Start date
B

Bucky

I am calling a C# method/DLL from Reporting Services. In the DLL, I am
referencing ConfigurationSettings.AppSettings["DBConnectionString"].
This should go in app.config in the caller's folder. This is fine when
the caller is a regular .NET application, but I don't know where to put
the app.config for Reporting Services.
 
1. During runtime the report is generated under the Report Server host
process so the <appSetting> section in web.config file should work. Try
rendering a report from the Report which has a textbox with the following
expression:
= System.Configuration.Configuration.AppSettings(<your config value>)
Please note that the web.config file already has a configuration section
so you need to add only the <appSettings> element. You should have the same
result when calling this from your DLL since it will be loaded in the RS
application domain.

2. During design time it is a bit trickier. Unfortunately, the current
configuration handler of the Report Designer doesn't seem to recognize
<appSettings>. However, you can render the report in debug mode by hitting
F5. This renders the report under ReportHost.exe. To get the config settings
working, create a ReportHost.exe.config in C:\Program Files\Microsoft SQL
Server\80\Tools\Report Designer and place your configuration section there
(the <configuration> element should be spelled with small "c"), e.g.:


<?xml version="1.0" encoding="utf-8" ?><configuration>
<appSettings>

<add key="serverUrl" value="http://localhost/reportserver" />
</appSettings>
</configuration>

b) To get the Preview tab working you could either check for Nothing and
replace that with a default value, or wrap the ConfigSettings.AppSettings
call to default to some default constant values. Once again, this is only
needed during design time. Your runtime report generation shouldn't need
this hack.



--
Hope this helps.

---------------------------------------------
Teo Lachev, MVP [SQL Server], MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
 
Just to clarify...by web.config I meant the Report Server web.config file
located in C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer if default setup settings have been accepted.

--
Hope this helps.

---------------------------------------------
Teo Lachev, MVP [SQL Server], MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
---------------------------------------------

Teo Lachev said:
1. During runtime the report is generated under the Report Server host
process so the <appSetting> section in web.config file should work. Try
rendering a report from the Report which has a textbox with the following
expression:
= System.Configuration.Configuration.AppSettings(<your config value>)
Please note that the web.config file already has a configuration section
so you need to add only the <appSettings> element. You should have the
same result when calling this from your DLL since it will be loaded in the
RS application domain.

2. During design time it is a bit trickier. Unfortunately, the current
configuration handler of the Report Designer doesn't seem to recognize
<appSettings>. However, you can render the report in debug mode by hitting
F5. This renders the report under ReportHost.exe. To get the config
settings
working, create a ReportHost.exe.config in C:\Program Files\Microsoft SQL
Server\80\Tools\Report Designer and place your configuration section there
(the <configuration> element should be spelled with small "c"), e.g.:


<?xml version="1.0" encoding="utf-8" ?><configuration>
<appSettings>

<add key="serverUrl" value="http://localhost/reportserver" />
</appSettings>
</configuration>

b) To get the Preview tab working you could either check for Nothing and
replace that with a default value, or wrap the ConfigSettings.AppSettings
call to default to some default constant values. Once again, this is only
needed during design time. Your runtime report generation shouldn't need
this hack.



--
Hope this helps.

---------------------------------------------
Teo Lachev, MVP [SQL Server], MCSD, MCT
Author: "Microsoft Reporting Services in Action"
Publisher website: http://www.manning.com/lachev
Buy it from Amazon.com: http://shrinkster.com/eq
Home page and blog: http://www.prologika.com/
---------------------------------------------

Bucky said:
I am calling a C# method/DLL from Reporting Services. In the DLL, I am
referencing ConfigurationSettings.AppSettings["DBConnectionString"].
This should go in app.config in the caller's folder. This is fine when
the caller is a regular .NET application, but I don't know where to put
the app.config for Reporting Services.
 
Back
Top