configSections in Web.config file

  • Thread starter Thread starter WFB
  • Start date Start date
W

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=Salesuser;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
 
Have you tried putting the referenced assemlies in thier own folders and
giving them thier own config files?
 
Is this possible to do through the IDE? Any time I add a refeence it adds
it to the /bin folder.

Thanks
Joe
 
Back
Top