In my WAP project I have a reference to another C# Project (non-web). In that C# project I have an app.config and I renamed it to [projectName].config
I then tried to grab a key from my [project].config from some code within my C# Project and it can’t find it:
return ConfigurationManager.AppSettings["somekey"]
So I am wondering why it can’t read my app.config. I would think that ConfigurationManager would be able to read keys form the Web project’s web.config AND my [projectName].config (app.config) file that is in my referenced project as well?
ConfigurationManager will read the configuration of the application’s host. In your case, the web app is the application’s host – therefore, calling ConfigurationManager will read from your web.config – even if you make calls to ConfigurationManager from a referenced dll.
If your web application references a dll, then the dll should get its configuration from the web.config. This is the best thing for the application. If the dll is referenced by multiple types of applications, the settings in the config may need to be different.