I know this maybe a duplicate, however all the posts so far cannot solve my issue.
I have a windows service, and I want this service to read from web.config. However, it keeps reading from machine.config. I have tried a lot of settings suggestions from many sites including SO, such as <appSettings file="location of web.config"
.
Do I need to reinstall after each change of the app.config? I have service.exe.config in the same folder as service.exe. What else I might have missed?
Another note, I have 2 websites in the IIS. How do I make sure that the window service takes the web.config that I want?
Some codes here to show how I did it:
private string uDir = ConfigurationManager.AppSettings["dir1"] + "\\dir1";
private string fDir= ConfigurationManager.AppSettings["dir2"] + "\\dir2";
private static string cs= ConfigurationManager.ConnectionStrings["cSqlServer"].ConnectionString.ToString();
private SqlConnection con = null;
The all the ConfigurationManager returns nothing, except ConnectionStrings which returns the value from machine.config.