By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,972 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,972 IT Pros & Developers. It's quick & easy.

'System.Configuration.ConfigurationSettings.AppSet tings' is obsolete !!

P: n/a
In trying to get the C# conversion code for Head First Design Patterns
to work I came accross a number of warnings. e.g.

Warning
Number: 10
Description: 'System.Configuration.ConfigurationSettings.AppSet tings'
is obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!System.Configuration.Configur ationManager.AppSettings'
E:\code\HeadFirstDesignPatternsInCSharp\Decorator. Starbuzz\Expresso.cs
Line: 31
Col: 30
Project: Decorator.Starbuzz

How do I fix it?

The file includes "System.Configuration", but when I write
ConfigurationManager I don't see the usual object there. How do I fix
this?
Here is the example offending file: Expresso.cs

using System;
using System.Configuration;

namespace HeadFirstDesignPatterns.Decorator.Starbuzz
{
/// <summary>
/// Summary description for Expresso.
/// </summary>
public class Expresso: Beverage
{
public Expresso()
{}

public override double Cost()
{
return GetSize(base.Size);
}

public override string GetDescription()
{
return "Expresso";
}

private double GetSize(BeverageSize size)
{
switch(size)
{
case BeverageSize.TALL:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeTall"]);
case BeverageSize.GRANDE:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeGrande"]);
case BeverageSize.VENTI:
return
Convert.ToDouble(ConfigurationSettings.AppSettings["ExpressoSizeVenti"]);
default:
return 1.50;
}
}
}
}
Jul 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a

If yours is a web application, try the following:

using System;
using System.Configuration;
using System.Web.Configuration;

In lieu of
ConfigurationSettings.AppSettings["myFunkyKey"]);
try
WebConfigurationManager.AppSettings["myFunkyKey"];
Jul 15 '07 #2

P: n/a

"mark4asp" <ma******@gmail.comwrote in message
news:cv********************************@4ax.com...
In trying to get the C# conversion code for Head First Design Patterns
to work I came accross a number of warnings. e.g.

Warning
Number: 10
Description: 'System.Configuration.ConfigurationSettings.AppSet tings'
is obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!System.Configuration.Configur ationManager.AppSettings'
E:\code\HeadFirstDesignPatternsInCSharp\Decorator. Starbuzz\Expresso.cs
Line: 31
Col: 30
Project: Decorator.Starbuzz

How do I fix it?
using System.Configuration;

ConfigurationManager.AppSettings

There is a System.Web.Configuration for Web configuration.

Jul 15 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.