Reputation: 13491
I am somewhat familiar with using configuration in .NET, but I am a little bit confused about something. You create an App.Config file to go with your exe, and any dlls you create use the same configuration file.
So how do you access the config in the configuration file from within your DLL? If you create a settings.settings inside the DLL project in Visual Studio it ends up blank with no settings in it.
Thanks.
Upvotes: 1
Views: 1194
Reputation: 1110
There's no easy way to do what you are asking (use the app.config file from your DLL project rather than or in addition to the app.config file for the EXE file that is using the DLL.)
See post #3 from this thread:
http://bytes.com/topic/c-sharp/answers/226001-problem-app-config-dll
Upvotes: 1
Reputation: 7986
You can use the System.Configuration.ConfigurationManager class to get the settings from the app.config (or web.config) from within a DLL. The AppSettings property will get the data from the appSettings section of the config file.
NameValueCollection settings = System.Configuration.ConfigurationManager.AppSettings;
string keyValue = settings["SomeKey"];
Upvotes: 4
Reputation: 1275
I think you have to share the application settings file for all of your dlls.
So you must have a different section inside this config file for each referenced assembly...
Upvotes: 2