views:

113

answers:

2

I'm working on a solution that has two projects: One ASP.NET web application, and one Custom Web Control library. The custom control library is used in the asp.net application. When I compile the solution, the app.config file of the custom web control library is not transfered with the dll to the ASP.NET apllications bin folder? How can I do that? And what is the proper class to read from that Config file

+1  A: 

When you run the library from the context of a web application then the .config file being used is based on that context alone. Therefore the settings you have must be available within the web.config for web usage and within the app.config for standalone / forms usage.

One solution I've used in the past is to write my own logic to export an embedded settings file from within the library out to the working directory and always reference this file directly from the working directory path. This means you can use the library settings from any context but ensure that the one point of contact for the settings is available.

+1  A: 

System.Configuration.ConfigurationManager.AppSettings is the NameValueCollection you access.

Also worth mentioning that machine.config can have a say in configuration, for good or ill.

FAQ here.

annakata