Cloud Stack Ninja

i have written an Windows Service and added an App.Config. The Layout of the App.Config looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
    <appSettings>
        <add key="Debug" value="true"/>
        <add key="Mail-To" value="test@test.de"/>
    </appSettings>
</configuration>

If i make a Build and install the Service, everything works so far and the "default" app.config-Settings are read and everything is fine. But if i change something in the "Service.App.Config" the new values are never read. Even if i restart the Service, the values stay the same. I googled and tried it with this code:

 var appSettings = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetEntryAssembly().Location).AppSettings;
                bool disarmed = Convert.ToBoolean(appSettings.Settings["Debug"].Value);

but even this does not help. Maybe someone can give me a hint how to resolve this and get the new values after i changed them in the App.Config.

Best Regards, Hendrik



Read more here: https://stackoverflow.com/questions/64403673/windows-service-net-app-config-not-working

Content Attribution

This content was originally published by Hendriks91 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: