Link to home
Start Free TrialLog in
Avatar of AstroGuy
AstroGuy

asked on

ConfigurationManager problems

I keep getting the following error message no matter what I try
The name 'ConfigurationManager' does not exist in the current context
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Configuration;
//using System.Configuration.Assemblies;
 
namespace C9_1AllAppSettings490
{
    class Program
    {
        static void Main(string[] args)
        {
            NameValueCollection AllAppSettings = ConfigurationManager.AppSettings; 
            Int32 Counter = 0;
            IEnumerator SettingsEnumerator = AllAppSettings.Keys.GetEnumerator(); 
            while (SettingsEnumerator.MoveNext())
            {
                Console.WriteLine("Item: {0}   Value: {1}", AllAppSettings.Keys[Counter], AllAppSettings[Counter]);
            } 
 
        }
    }
}

Open in new window

Avatar of jinal
jinal
Flag of India image

Add reference to assembly System.Configuration.

System.Configuration.dll refrence is missing.


Avatar of AstroGuy
AstroGuy

ASKER

jinal,
"using System.Configuration;" is plainly visible in the code above.  /the system will not accept
using System.Configuration.dll
What are you refering to ??;

Avatar of Avodah
Namespaces can span across assemblies - although you can include this namespace without any errors the class ConfigurationManager / some of its members (possible due to partial classes) are not available until you reference the assembly System.Configuration.dll.

As stated by Jinal you need to add a reference  to System.Configuration.dll and then the System.Configuration.ConfigurationManager will become available.

Adding and assembly reference and using a namespace are two different things.

http://msdn.microsoft.com/en-us/library/wkze6zky(VS.80).aspx
The code you see is all the code there is.

When I add using System.Configuration.dll.I get and error.
I don't understand.
ASKER CERTIFIED SOLUTION
Avatar of jinal
jinal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry Jinal that it took so long to get back to you.