I want to access the "appSettings" section of a web.config file. According to MSDN and multiple other sources, the following should work:
System.Configuration.Configuration config =
WebConfigurationManager.OpenWebConfiguration("/rootPath");
I received this error on the second configuration (System.Configuration.Configuration):
The type or namespace name 'Configuration' does not exist in the namespace 'System.Configuration'(are you missing an assembly reference?)
I received an additional error on system (System.Configuration.Configuration):
The type 'System.Configuration.Configuration' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Configuration, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Addressing the first error, I have a reference to System.Configuration. When I look in Object Browser, it contains a class definition for Configuration.
Addressing the second error, the reference is for version 2.0.50727. Is there a version 2.0.0.0?
The second error popped up after I deleted, and re-added the reference to System.Configuration. Also, after re-adding the reference it now displays as "System.configuration" in my references. Note the lowercase c.
Additional Notes
Things I've tried and failed:
- Deleted and added the reference to System.Configuration
- Deleted all references for the project and added them back
- Checked out a clean solution from SVN
I created a test solution and had no problems accessing the class in the System.Configuration namespace.
Any ideas on what is going on (how did I eff this up)? What avenues can I try to fix it?