delete
delete

Reputation:

"This method is obsolete" warning when trying to use App.config file

Here's my method:

public IList<Member> FindAllMembers()
{
    using (WebClient webClient = new WebClient())
    {
        string htmlSource = webClient.DownloadString(ConfigurationSettings.AppSettings["MemberUrl"]);
    }

    XDocument response = XDocument.Parse(htmlSource);
}

It's recommending I use the new ConfigurationManager.AppSettings, but I can't find it anywhere in intellisense. I'm sure I'm importing the correct namespaces. Do I need to reference something as well?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Xml.Linq;
using SharpDIC.Api.Interfaces;
using SharpDIC.Api.Models;
using System.Configuration;

namespace SharpDIC.Api.Concrete
{
    class XmlMemberFinder : IMemberFinder
    {
        public IList<Member> FindAllMembers()
        {
            using (WebClient webClient = new WebClient())
            {
                string htmlSource = webClient.DownloadString(ConfigurationSettings.AppSettings["MemberUrl"]);
            }

            XDocument response = XDocument.Parse(htmlSource);
        }

Upvotes: 0

Views: 1933

Answers (6)

Rakesh Arrepu
Rakesh Arrepu

Reputation: 71

Right click on references-->select Assemblies on left side--> Check System.Configuration.dll and System.Configuration.install.dll--> Click ok.

Hope this resolves the issue as mine !

Upvotes: 0

curiousBoy
curiousBoy

Reputation: 6834

I had the same issue. Try ConfigurationManager instead of ConfigurationSettings

Upvotes: 2

Guffa
Guffa

Reputation: 700322

You need a reference to the System.Configuartion.dll library in your project. Then you can use it:

string htmlSource = webClient.DownloadString(ConfigurationManager.AppSettings["MemberUrl"]);

Upvotes: 0

SwDevMan81
SwDevMan81

Reputation: 49978

Add System.Configuration.dll to your references

Upvotes: 0

Jon
Jon

Reputation: 16728

It is in the System.Configuration namespace. Try adding a reference to the System.Configuration assembly.

System.Configuration.ConfigurationSettings is in the System assembly, which is why you can use it without adding a reference.

Upvotes: 5

Oded
Oded

Reputation: 499002

It is in System.Configuration.

So you should be able to see it.

Are you missing the assembly reference?

Upvotes: 0

Related Questions