Change app.config value of another project at runtime

I have two projects under the same solution. I want to change the value of the app.config project, but I don’t know how.

Project A

Project B

They should work as such: Project A is a coded UITest and I want to modify its config file.

This is how I tried

string abc = @"absolutePath\app.config";
Configuration configuration =                     ConfigurationManager.OpenExeConfiguration(abc);
configuration.AppSettings.Settings["areaCode"].Value = "new";
configuration.Save();
ConfigurationManager.RefreshSection("appSettings");

      

The app.config project of the project I want to change is .dll (codedUiTestProject)

This is my node structure:

<appSettings>
    <add key="LogFilePath" value="" />
    <add key="areaCode" value="steamAccessDummy"/>
</appSettings>

      

I need help, thanks! Are there any other solutions?

+3


source to share


1 answer


You tried configuration.Save(ConfigurationSaveMode.Full, true);



0


source







All Articles