Changes in App.config do not reflect after restarting the application

I use the app.config file to store the dynamic parameters of my application. The problem is that when I change the value in the app.config file and run the application, it does not load the new value from the configuration file. It looks like the values ​​in the app.config file are only read and inserted into the exe file at compile time!

This is how I read the configuration file:

public class Helper
{
    static Helper()
    {
        Foo = ConfigurationManager.AppSettings["Foo"];
    }
    public static string Foo { get; set; }
}

Did I miss something?

+3
source share
3 answers

Are you sure you changed the correct file? You do not want to modify the app.config file, but the file is <exename>.exe.configin the same directory as .exe

app.config - , ide, <exename>.exe.config ..exe , .config, .

+20

. , :

public static class Helper
{
    public static string Foo 
    { 
        get
        {
            return ConfigurationManager.AppSettings["Foo"];
        }
    }
}

, , , ConfigurationManager.AppSettings["Foo"] () - , .

+1

IISReset?

, Microsoft.NET,

WINDOWS\Microsoft.NET\Framework\vXXXXX\Temporary ASP.NET Files. 

.

0

Source: https://habr.com/ru/post/1725834/


All Articles