Click to See Complete Forum and Search --> : help. how to read dll.config when adding to other application


comicrage
June 4th, 2009, 03:28 PM
Hi,

I just written a class library dll which generates a dll.config. When I added the project to another web application project as a reference, I don't see the configuration being read. I checked the bin\debug and even copied the dll.config to the unit test Out folder and still the same problem. I would think that the projectname.dll would automatically look for and read the projectname.dll.config. When I step through the code from the web app to the project method, the following statement inside the dll can read anything


FileName = ConfigurationManager.AppSettings["textFileName"];


Any help would be appreciated.

Thanks

Arjay
June 4th, 2009, 04:28 PM
By default, there can only be one config file for an 'application'.

So when your assembly (dll) is used by another project (app, service, web, etc), the Configuration Manager will read that project's config file. This can be an app.config or web.config file.

You just need to copy the contents of your dll.config into the other main project's config file.

comicrage
June 4th, 2009, 05:01 PM
I prefer not to ask everyone who is using my dll to copy all the content to their app.config. I would predict that the manager will say no way. The class has alot of settings including the enterprise library application blocks configuration. The original goal is to add my project to their solution and they can easily use my code instead of writing their own. This class will be used by many people. I can't just ask everyone to copy and post to their app.config or web.config. Is there an easy way to load not just their .config and mine?

Arjay
June 4th, 2009, 05:18 PM
For your settings you have an option to load the dll.config file as an xml file (for example via XmlSerialization). However, the Enterprise Library is going to be expecting its settings to be located in the application's config file.