大家好,
我试图检索SQLServer的连接字符串形成我在我的Windows服务项目写在C#4 app.config文件。
我已经把在顶部...
使用System.Configuration;
然后我试着在我的启动事件...
protected override void OnStart(string[] args)
{
try
{
cStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
}
catch (Exception e)
{
File.AppendAllText(Environment.CurrentDirectory + "\\ServiceMessages.txt", "\r\nOn start Error - " + e.Message);
}
}
CSTR是前面声明的一个实例串。
但它不会编译和我intellisence突出ConfigurationManager中字,说在目前情况下,它不存在。
我在做什么错吗?
谢谢。