473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

configSections in Web.config file

WFB
Hi

I have an application with a couple of referenced assemblies. The
referenced assemblies and my application all share a few configuration
settings with the same name but different values. Is there a way to set up
the config file to recognize this? Im thinking section name elements, but
am not having much luck. Lets say the project has a StoreLocator assembly,
a ProductGuide assembly and the main web site. All three have a value in
thier individual config files named "connectionString", and in each case
this value is different. When the web site references them, they read the
"connectionString" value from the master (for lack of a better term)
applications config file. I would like to set up this config file somehow
where I can store three "connectionString" values, but each assembly knows
which value belongs to it.

Something like this is how I would envision it working

<configuration>
<configSections>
<section name="Sales" type="MyCompany.Sales"/>
<section name="CustomerService"
type="MyCompany.CustomerService"></section> <!-- name of assemby -->
</configSections>

<!-- information for the current application -->
<appSettings>
<add key="connectionString"
value="server=MyServer;database=location;uid=user; pwd=password"></add>
<add key="LogPath" value="c:\temp\"></add>
<add key="PreCache" value="True"></add>
<add key="LimitSearchBySection" value="50"></add>
</appSettings>

<!-- information for the MyCompany.Sales dll -->
<Sales>
<add key="connectionString"
value="server=SalesServer;database=Sales;uid=Sales user;pwd=password"></add>
</Sales>

<!-- information for the MyCompany.CustomerService dll -->
<Sales>
<add key="connectionString"
value="server=CSServer;database=Sales;uid=cssuser; pwd=password"></add>
</Sales>

</configuration>
Thanks for any help or insight.
Joe
Nov 17 '05 #1
2 2396
Have you tried putting the referenced assemlies in thier own folders and
giving them thier own config files?

"WFB" <x@hotmail.com> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
Hi

I have an application with a couple of referenced assemblies. The
referenced assemblies and my application all share a few configuration
settings with the same name but different values. Is there a way to set up the config file to recognize this? Im thinking section name elements, but
am not having much luck. Lets say the project has a StoreLocator assembly, a ProductGuide assembly and the main web site. All three have a value in
thier individual config files named "connectionString", and in each case
this value is different. When the web site references them, they read the
"connectionString" value from the master (for lack of a better term)
applications config file. I would like to set up this config file somehow
where I can store three "connectionString" values, but each assembly knows
which value belongs to it.

Something like this is how I would envision it working

<configuration>
<configSections>
<section name="Sales" type="MyCompany.Sales"/>
<section name="CustomerService"
type="MyCompany.CustomerService"></section> <!-- name of assemby -->
</configSections>

<!-- information for the current application -->
<appSettings>
<add key="connectionString"
value="server=MyServer;database=location;uid=user; pwd=password"></add>
<add key="LogPath" value="c:\temp\"></add>
<add key="PreCache" value="True"></add>
<add key="LimitSearchBySection" value="50"></add>
</appSettings>

<!-- information for the MyCompany.Sales dll -->
<Sales>
<add key="connectionString"
value="server=SalesServer;database=Sales;uid=Sales user;pwd=password"></add> </Sales>

<!-- information for the MyCompany.CustomerService dll -->
<Sales>
<add key="connectionString"
value="server=CSServer;database=Sales;uid=cssuser; pwd=password"></add>
</Sales>

</configuration>
Thanks for any help or insight.
Joe

Nov 17 '05 #2
WFB
Is this possible to do through the IDE? Any time I add a refeence it adds
it to the /bin folder.

Thanks
Joe

"Todd Bellamy" <to*********@hotmail.com> wrote in message
news:Y4*********************@news04.bloor.is.net.c able.rogers.com...
Have you tried putting the referenced assemlies in thier own folders and
giving them thier own config files?

"WFB" <x@hotmail.com> wrote in message
news:O%****************@TK2MSFTNGP09.phx.gbl...
Hi

I have an application with a couple of referenced assemblies. The
referenced assemblies and my application all share a few configuration
settings with the same name but different values. Is there a way to set

up
the config file to recognize this? Im thinking section name elements, but am not having much luck. Lets say the project has a StoreLocator

assembly,
a ProductGuide assembly and the main web site. All three have a value in thier individual config files named "connectionString", and in each case
this value is different. When the web site references them, they read the "connectionString" value from the master (for lack of a better term)
applications config file. I would like to set up this config file somehow where I can store three "connectionString" values, but each assembly knows which value belongs to it.

Something like this is how I would envision it working

<configuration>
<configSections>
<section name="Sales" type="MyCompany.Sales"/>
<section name="CustomerService"
type="MyCompany.CustomerService"></section> <!-- name of assemby -->
</configSections>

<!-- information for the current application -->
<appSettings>
<add key="connectionString"
value="server=MyServer;database=location;uid=user; pwd=password"></add>
<add key="LogPath" value="c:\temp\"></add>
<add key="PreCache" value="True"></add>
<add key="LimitSearchBySection" value="50"></add>
</appSettings>

<!-- information for the MyCompany.Sales dll -->
<Sales>
<add key="connectionString"

value="server=SalesServer;database=Sales;uid=Sales user;pwd=password"></add>
</Sales>

<!-- information for the MyCompany.CustomerService dll -->
<Sales>
<add key="connectionString"
value="server=CSServer;database=Sales;uid=cssuser; pwd=password"></add>
</Sales>

</configuration>
Thanks for any help or insight.
Joe


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jaco de Villiers | last post by:
Hi, I have added the following group and section: <configSections> <section name="sampleSection" type="System.Configuration.SingleTagSectionHandler" /> <sectionGroup name="tilos.sdk">...
3
by: Stephen Woolhead | last post by:
I have a web application that has several ConfigSection handlers defined, one in the web application it's self and several in external assemblies. I am using VS's built in web server My problem...
1
by: eje | last post by:
I want to use configSections for applicationsettings but I get Exception creating section handler. My code in web.config: <configuration> <configSections> <sectionGroup...
1
by: Andrea Moro | last post by:
In web.config file I do as follow: <configsections> <sectiongroup name="Database"> <section name="Access" type=".... Ok problem is there in type. According to the help is only needed the...
5
by: wolfgang wagner | last post by:
hi all! i'm trying to define a custom config section like described in the online help of VS2005: <configuration> <configSections> <section name="sampleSection"...
0
by: Jeffrey Hornby | last post by:
I'm getting "Exception in configuration section handler" when I start my web program and its indicating the opening tag of a custom configSection in my web.config. The relevant parts of the...
1
by: Dave | last post by:
I'm access a non default application config file with OpenMappedExeConfiguration() and it works great for "appSettings" values, but I cannot get it to work for configSection values / with...
3
by: =?Utf-8?B?TUNN?= | last post by:
I have the following configSections in my web.config. Again, it's not clear to me what this is doing because I can delete the entire section and the application compiles and runs fine. Why do I...
7
by: =?Utf-8?B?RXZl?= | last post by:
I have the following sections defined in my app.config file: <configSections> <section name="1" type="System.Configuration.DictionarySectionHandler" /> <section name="2"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.