Dip
Dip

Reputation: 363

ConfigurationSettings.AppSettings Obsolete

I am getting a warning when using this:

ConfigurationSettings.AppSettings("ArbitraryName").ToString()

The warning:

Public Shared ReadOnly Property AppSettings As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'.

I have tried using ..

ConfigurationManager.AppSettings["ArbitraryName"].ToString();

*The issue with this  is that it cannot be casted as a string.* 

Note: My System.Configuration is pointing to C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll

Upvotes: 0

Views: 2650

Answers (2)

Cloudswalker
Cloudswalker

Reputation: 55

I had similar issue in aspx file. Error message: Too many arguments to 'Public Shared Overloads ReadOnly Property AppSettings As NameValueCollection. Fix: Change

<a href='<%ConfigurationManager.AppSettings("URL") %>'></a>

To

<a href='<%=ConfigurationManager.AppSettings("URL") %>'></a>

Upvotes: 0

Sateesh Pagolu
Sateesh Pagolu

Reputation: 9606

This should work..

System.Configuration.ConfigurationManager.AppSettings("ArbitraryName")

Upvotes: 1

Related Questions