20080529转载:System.Configuration.ConfigurationSettings.AppSettings”已过时

System.Configuration.ConfigurationSettings.AppSettings”已过时
2007年11月19日 星期一 16:57

使用VS 2005,习惯性的使用ConfigurationSettings类来读取应用程序配置文件的信息时,却被编译器提示说

警告“System.Configuration.ConfigurationSettings.GetConfig(string)”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.GetSection”

警告   1 “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”

注意:默认没有引用ConfigurationManager类,所以找不到System.Configuration命名空间的 ConfigurationManager类.

解决:首先添加对System.Configuration.dll 文件的引用;:在将"System.Configuration.ConfigurationSettings.GetConfig替换为System.Configuration.ConfigurationManager.GetSection

将“System.Configuration.ConfigurationSettings.AppSettings”替换为System.Configuration.ConfigurationManager.AppSettings”


MS对这一点提示比较隐晦而已——
This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings
上面那段话多了System.Configuration!


http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece763104c8c711923d030678197027fa3c215cc790516163cb4fb79794c53ce95223a54b2121abdaf2b70630973bdcbcc8e4bdbbbc5797edc2660751d8246148013b8cb317f877fce4eacf259b1b5a16fcffa89869814008c085826c1a7cd1c5b489f2ee71541f4a6ee5f142f43f8af7132b91f2c75ca6257b636ee90397973f7e1ac2f5bb329&p=882a973792904eaf5efcc0274e4e&user=baidu

posted @ 2008-05-29 03:58  以函  阅读(341)  评论(0编辑  收藏  举报