I have multiple class library projects in solution. I need to store configuration data some where for each library project, so my question is can each of library projects contain app config file?
Asked
Active
Viewed 38 times
1 Answers
0
For class library projects an assemblyname.dll.config is generated for them by default if an App.config is available.
If you don't want to put the required settings in the app.config/web.config of the entry point assembly you can access it as below.
var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
var value = config.AppSettings["key"];
This assumes that the assemblyname.dll.config file is located in the same directory with the assembly.
Note that if you are calling this outside the assembly in questions it will simply refer to whatever assembly is executing at that point.

scartag
- 17,548
- 3
- 48
- 52