在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”


解决方法:

首先添加对System.Configuration.dll 文件的引用,既在该项目中添加引用,在浏览中找到System.Configuration.dll文件,一般该文件在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727文件夹中;

其次再把.net 1.0下的“System.Configuration.ConfigurationSettings.AppSettings”索引器换成.net 2.0下的“System.Configuration.ConfigurationManager.AppSettings”索引器。

把"System.Configuration.ConfigurationSettings.GetConfig换成System.Configuration.ConfigurationManager.GetSection

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-11-28
  • 2021-11-11
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案