I created a Windows service used to execute automated procedures (.Net code) for multiple periodic operations, like backups, sanity checks, reports generation, etc. After building the project, I installed the service with installutil
. Everything worked great.
I decided to move various "static" parameters for these automated procedures in the App.config
file. I uninstalled the previous version of the service with installutil /u
and built the new version of the project. In my build output folder, there's a AppName.exe
file and a AppName.exe.config
file, as I would expect. I installed the new version of the service, again with installutil
from the VS 2012 Developer Command Prompt as an administrator.
The problem is that the service doesn't seem to be able to read the configuration file from the ConfigurationManager
. The call for ConfigurationManager.AppSettings("paramname")
doesn't fail, but the resulting parameter value is an empty string. As far as I know, the problem occurs for all parameters and not only for specific ones. The parameters are located in the <appSettings>
section, under <configuration>
, like I've done multiple times before in various projects.
I don't know if it can help, but my service runs on the LocalSystem
account and starts automatically after installation and with Windows.
What did I do wrong?
Edit: I already tried uninstalling/re-installing the service (multiple times), like some stackoverflow answers suggests. Also, I'm not looking to update/refresh the file at runtime.