警告 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問題
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.