使用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”

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-11-28
  • 2021-06-13
  • 2022-12-23
  • 2021-10-01
  • 2021-04-25
猜你喜欢
  • 2022-01-09
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案