Its a windows service and I can read appkeys
from app.config
but can't read from extnernal appSettings file which is on the same path. Below is my app.config:
<appSettings file="Scheduler.dev.AppSettings.config">
<add key="ErrorEmailTo" value="xxx@domain.com" />
</appSettings>
My external appSetting file is as below:
<appSettings>
<add key="ErrorEmailFrom" value="test@xxxxxx.com" />
<add key="ErrorEmailhost" value="smtp.ddd.local" />
<add key="ErrorEmailPort" value="25" />
<add key="ErrorEmailEnableSsl" value="true" />
<add key="ErrorEmailUserName" value="test.user@xxxxxxxx.com" />
<add key="ErrorEmailPassword" value="password" />
</appSettings>
Below is my code to read keys:
protected override void GetDetails()
{
try
{
var ErrorEmailTo = ConfigurationManager.AppSettings["ErrorEmailTo"];
var ErrorEmailFrom = ConfigurationManager.AppSettings["ErrorEmailFrom"];
var ErrorEmailhost = ConfigurationManager.AppSettings["ErrorEmailhost"];
var ErrorEmailPort = ConfigurationManager.AppSettings["ErrorEmailPort"];
var ErrorEmailEnableSsl = ConfigurationManager.AppSettings["ErrorEmailEnableSsl"];
var ErrorEmailUserName = ConfigurationManager.AppSettings["ErrorEmailUserName"];
var ErrorEmailPassword = ConfigurationManager.AppSettings["ErrorEmailPassword"];
}
catch (Exception ex)
{
throw ex;
}
}
I can code can read first key which is coming form app.config
but others remain null. Even if I move my keys into app.config
I can read all keys using above code.
What I have tried is:
- checked names, path
- deleted all temp/ bin files but no luck
Please help.