当我从app.config中调用它时。在代码的下一部分显示错误
static void Main(string[] args)
{
string Sys = ConfigurationManager.AppSettings["appsettings"];
string[] sys1 = Sys.Split(',');
List<string> symbols = new List<string>();
foreach (string item in sys1)
{
symbols.Add(item);
}
}
string idExchangeId = ConfigurationManager.AppSettings["idExchangeId"];
Logger.Write("########## Commodities Control Rate Puller Program starting up ########## ");
session = new RatePullerSession(hostname,
port,
username,
password,
idExchangeId,
symbols,
userModeOutputTokens);
session.Initialize();
session.Logon();
session.SubscribeSymbols();
session.querySubscribedSymbols();
session.ListenStreamingUpdates();
}
}
}
答案 0 :(得分:0)
看起来您正在尝试检索Configuration.AppSettings中保留的所有值。为此,请尝试使用ConfigurationManager.Appsettings.AllKeys,然后执行以下操作:
var settings = ConfigurationManager.AppSettings.Keys;
foreach (string setting in settings)
{
symbols.Add(ConfigurationManager.AppSettings[setting]);
}