Thread: configuration settings problem

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    44

    configuration settings problem

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Configuration;
    
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string astring;
                astring = ConfigurationSettings.AppSettings["avalue"];
                Console.WriteLine(astring);
            }
        }
    }
    Warning 1 'System.Configuration.ConfigurationSettings.AppSet tings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.Configur ationManager.AppSettings' C:\Documents and Settings\mixalis\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs 14 23 ConsoleApplication1

    In another forum I found :

    The most likely issue is that you're missing a reference to the System.Configuration.dll. This particular deprecation was certainly one of the most confusing, because the new type is actually in a completely different assembly. System.Configuration.ConfigurationSettings was in System.dll.
    but I cannot understand what I should change!!! Can you help???

    xml file
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <appSettings>
    <add key="avalue" value="mike" />

    </appSettings>
    </configuration>
    Last edited by mixalissen; 05-28-2008 at 08:05 AM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Do exactly as you were told:

    ConfigurationSettings.AppSettings is obsolete.

    Instead, use ConfigurationManager.AppSettings'

    To do so, don't forget to include System.Configuration in your references.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very strange bootup problem
    By BobMcGee123 in forum Tech Board
    Replies: 5
    Last Post: 01-10-2007, 12:05 AM
  2. delete[] problem with release config...
    By mikahell in forum C++ Programming
    Replies: 8
    Last Post: 08-21-2006, 10:37 AM
  3. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM