我試圖從app.config中ConfigurationManager.AppSettings [關鍵]總是空
這讓在appSetting節的關鍵「的suser」的值是我class.cs代碼
string sUsr = ConfigurationManager.AppSettings.Get["sUser"];
但始終爲空。
我試試這個代碼(我把它從MSDN):
// Get the configuration file.
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Get the appSettings section.
AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");
// Get the auxiliary file name.
Console.WriteLine("Auxiliary file: {0}", config.AppSettings.File);
但它表示該文件空
而且我現在用的是stting控制檯寫這些屬性和它的作品,如果我獲得使用
string sUsr = WIW.Business.Properties.Settings.Default.sUser;
的應用程序,但我要使用該類作爲參考的網站,並在網站上的web.config中我無法配置這些設置
你可以粘貼web.config的AppSettings部分作爲參考嗎?在附註中,你甚至不需要使用'config.GetSection(「appSettings」)'。 – 2010-04-17 22:58:06