警告 1 “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings” D:/aspnet/JXC/DAL/SqlConn.cs 12 24 DAL
在使用app.config里面的数据库配置字符串时候,使用ConfigurationSettings出现上面的错误。
于是转而想使用ConfigurationManager类来使用,结果在System.Configuration命名空间下怎么也找不到 ConfigurationManager类,最后才知道原来还要添加对System.Configuration.dll 文件的引用。
对于为何要再添加System.Configuration.dll 文件的引用,还是不明白,有待学习。
最后:
using System.Configuration;
ConnectionStringSettings s = ConfigurationManager.ConnectionStrings["DAL.Properties.Settings.JXCConnectionString"];
关于System.Configuration.ConfigurationManager.AppSettings问题
最新推荐文章于 2025-01-14 18:41:29 发布