configSections in Web.config file

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
 
T

Todd Bellamy

Have you tried putting the referenced assemlies in thier own folders and
giving them thier own config files?
 
W

WFB

Is this possible to do through the IDE? Any time I add a refeence it adds
it to the /bin folder.

Thanks
Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top