"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 refere开发者_开发问答nce 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);
}
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.
I had the same issue. Try ConfigurationManager
instead of ConfigurationSettings
It is in System.Configuration
.
So you should be able to see it.
Are you missing the assembly reference?
Add System.Configuration.dll to your references
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"]);
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 !
精彩评论