This is the expected behavior.
You may have separate configuration files, but you will have to read them manually, the two methods you are quoting will capture information from the assembly configuration file you are running. >
You can use the ConfigurationManager.OpenExeConfiguration
to capture an object of type Configuration
and fetch data saved in appSettings
of it.
Something like:
public string GetAppSetting(Configuration config, string chave)
{
var element = config.AppSettings.Settings[chave];
return element?.Value ?? "";
}
The use would be like this
string configLocal = this.GetType().Assembly.Location;
var config = ConfigurationManager.OpenExeConfiguration(configLocal);
string myValue = GetAppSetting(config, "chave");