我使用System.Configuration在我的组装 但只要我实现的getter/setter方法 上的代码 被灰色的顶部System.Configuration链接(在装配不使用)System.Configuration配置管理器
配置&配置管理器得到下划线 红色是蓝绿色的。错误消息是:
找到类型和/或命名空间名称配置不能 。 (你是否缺少...等)
奇怪的是,在我的测试程序中,相同的代码 运行没有错误。有什么我需要 更改属性或程序集本身到 获取System.Configuration运行?
谢谢你的帮助!
public string getAppSetting(string key)
{
//Load AppSettings
Configuration config = ConfigurationManager.
OpenExeConfiguration(
System.Reflection.Assembly.
GetExecutingAssembly().Location);
//Zurückgeben der dem Key zugehörigen Value
return config.AppSettings.Settings[key].Value;
}
public void setAppSetting(string key, string value)
{
//Save AppSettings
Configuration config = ConfigurationManager.
OpenExeConfiguration(
System.Reflection.Assembly.
GetExecutingAssembly().Location);
//Überprüfen ob Key existiert
if (config.AppSettings.Settings[key] != null)
{
//Key existiert. Löschen des Keys zum "überschreiben"
config.AppSettings.Settings.Remove(key);
}
//Anlegen eines neuen KeyValue-Paars
config.AppSettings.Settings.Add(key, value);
//Speichern der aktualisierten AppSettings
config.Save(ConfigurationSaveMode.Modified);
}
你是什么意思“System.Configuration链接”? – spender