简体   繁体   English

在运行时更改其他项目的app.config值

[英]Change app.config value of other project at runtime

I have two projects under the same solution. 我在同一解决方案下有两个项目。 I want to change the value of a project's app.config but I don' know how to do it 我想更改项目app.config的值,但我不知道该怎么做

Project A 项目A.

Project B 项目B.

They are supposed to run as such : Project A is a codedUITest, and I want to change a value of it's configuration file. 他们应该这样运行:项目A是一个codedUITest,我想更改它的配置文件的值。

This is how I have tried 这就是我尝试过的方式

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

The project's app.config that I want to modify is a .dll (codedUiTestProject) 我要修改的项目的app.config是.dll(codedUiTestProject)

This is my node's structure : 这是我的节点结构:

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

I need some help, thanks ! 我需要一些帮助,谢谢! Are there any other solutions ? 还有其他解决方案吗?

您是否尝试过configuration.Save(ConfigurationSaveMode.Full, true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM