| Author: Tamim Sadikali 29 Jul 2004 | Member Level: Bronze Points : 0 |
Tony,
On someone asking this question you directed them to your 'creating custom config sections' entry. This does not work if you want to call the app.config/web.config from within the class library. Any other thoughts??
|
| Author: Tamim Sadikali 29 Jul 2004 | Member Level: Bronze Points : 0 |
Tony,
On someone asking this question you directed them to your 'creating custom config sections' entry. This does not work if you want to call the app.config/web.config from within the class library. Any other thoughts??
|
| Author: Tony John 29 Jul 2004 | Member Level: Gold Points : 0 |
Reading the app.config from class library is no different from reading it from anywhere else. You can use the same syntax.
The only thing is, you cannot have an app.config/web.config for a class library. The config file should be attached to the main application. The class library cannot run on its own. It will always run as part of another executable. So, if you use ConfigurationSettings.AppSettings["Key"] from a class library, it will look for the Key in the entry point application's config file.
In case of web applications, you can have all the keys in the root web.config and all class libraries can read from it.
|
| Author: Gyanendra Kumar Nayak 16 Sep 2008 | Member Level: Silver Points : 1 |
The example posted here is very simple to understand the logic. Keep it up...Thanks a lot for this
|
| Author: Bhavin 19 Jun 2010 | Member Level: Bronze Points : 2 |
Its great to see this.....as a student i hv used it in my project also...now i want to add sectionGroup of own section... eg.
value="Welcome to HR Department" /> value="________" /> value="Welcome to Marketing Department" /> value="_____________" />
so how do i achieve d same? however i hv tried but it saya dat "could nt found information for Department" & same for inner level tag also I think m missing type of sectionGroup or of any others
|
| Guest Author: Ofer 24 May 2012 |
Very Good!!!
|
| Guest Author: Alex 26 Aug 2012 |
oh !
I've been looking for this one day, and you did it in a few lines. While the others were complex things. I love you.
|
| Author: Dharmaraj Nagarajan 27 Feb 2013 | Member Level: Gold Points : 5 |
Tony,
I noticed when I tried adding custom section in App.config file and retrieving values from App.config got below error.
Error Message Could not load type 'System.Configuration.NameValueSelectionHandler' from assembly 'System.Configuration, Version=2.0.0.0
Workaround Need to add the below line in App.config file, when defining the custom section. These will help in avoiding Error.
type="System.Configuration.NameValueSectionHandler,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
I think this will help users who experiencing error. Note These error I had noticed when running in Windows 7 machine with Home Edition, not sure every one will face the issue. Happy coding.
|