Jump to content
pedro.peixoto

method is obsolete, it has been replaced

Recommended Posts

pedro.peixoto

Boa tarde a todos mais uma vez ;)

Se alguém me puder ajudar com este erro agradecia.

Estou a programar em C# VisualStudio 2010 e estou a guardar a minha connectionString em app.config e ao atribuir a uma string o valor guardado na config:

string StrCon = ConfigurationSettings.AppSettings["StrCon"];

estou a receber este warning:

Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'

Alguém me sabe dizer como resolvo isto?

Obg

Share this post


Link to post
Share on other sites
pedro.peixoto

Desculpa a pergunta ignorante mas

E como é que eu faço isso?

Estou a usar o system.configuration e não me aparece ConfigurationManager, apenas ConfigurationSettings.

Share this post


Link to post
Share on other sites
Rechousa

Precisas de fazer duas coisas:

- Adicionar a Assembly System.Configuration ao teu projecto (Em cima do projecto -> botão direito do rato -> Add Reference -> .Net -> System.Configuration)

- usar a assembly:

using System.Configuration;


Pedro Martins

Sharing is Knowledge!

http://www.linkedin.com/in/rechousa

Share this post


Link to post
Share on other sites
pedro.peixoto

Obrigado!!

Faltava só adicionar a Assembly.

Bastou isso para o warning desaparecer, mesmo estado com ConfigurationSettings, de qualquer forma já alterei para o ConfigurationManager.

Obrigado  ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.