C#之app.config、exe.config和vshost.exe.config作用区别
vshost.exe.config是程序运行时的配置文本
exe.config是程序运行后会复制到vshost.exe.config
app.config是在vshost.exe.config和exe.config没有情况起作用,从app.config复制到exe.config再复制到vshost.exe.config
写配置文件都是写到exe.config文件中了,app.config不会变化。
app.config只在exe.config丢失的情况下在开发环境中重新加载app.config,vshost.exe.config和exe.config会自动创建内容跟app.config一样。
vshost.exe.config和app.config两个文件可不要,但exe.config文件不可少。
网络上有很多文章是讲app.config读写方法的,可是事实上这个文件程序就不能改变它。
public static void SaveAppSettings(string aKey, string aValue)
{
// 创建配置文件对象
string file = System.Windows.Forms.Application.ExecutablePath; //此处修改为.vshost.exe.Config的内容
// System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(file); if (config.AppSettings.Settings[aKey] != null)
{
// 修改
config.AppSettings.Settings[aKey].Value = aValue;
}
else
{
// 添加
AppSettingsSection ass = (AppSettingsSection)config.GetSection("appSettings");
ass.Settings.Add(aKey, aValue);
} // 保存修改
config.Save(ConfigurationSaveMode.Modified); // 强制重新载入配置文件的连接配置节
ConfigurationManager.RefreshSection("appSettings");
}
C#之app.config、exe.config和vshost.exe.config作用区别的更多相关文章
- app.config *.exe.config 和*.vshost.exe.config基础学习
一.问题描述 在使用config文件来保存一些参数,便于下次启动程序时自动加载上次设置的参数的功能时, 碰到个问题,vs2010下调试运行程序始终无法实现config记录上次参数值,而直接运行exe程 ...
- Debug目录、Release目录,bin目录、obj目录,vshost.exe.config文件、.exe.config文件分析【C#】
原文地址:http://blog.csdn.net/itwit/article/details/6803338 今天写程序的时候,需要更改.exe.config文件中的引用的webservice地址, ...
- 宿主进程 [*.vshost.exe] & [*.vshost.exe.config]
宿主进程 [*.vshost.exe] & [*.vshost.exe.config] pdb文件: 英文全称:Program Database File 中文全称:程序数据库 文件 Debu ...
- redis启动错误: Warning: no config file specified, using the default config. In order to specify a config
redis启动错误: Warning: no config file specified, using the default config. In order to specify a config ...
- Visual Studio 不生成.vshost.exe和.pdb文件的方法【转】
Visual Studio 不生成.vshost.exe和.pdb文件的方法[转] 使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost ...
- [C#]Hosting Process (vshost.exe)
写在前面 最近在群里,有朋友问起这个vshost.exe进程到底是什么?当时确实不知道是个什么东东,给人的感觉是,经常看到它,就是在启动一个项目的时候,经常看到它,就是没细研究它是啥玩意儿.既然遇到了 ...
- Visual Studio 不生成.vshost.exe和.pdb文件的方法
使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost.exe」和「.pdb」的文件. 一.先解释一下各个文件的作用: .pdb文件: 程 ...
- 宿主进程 vshost.exe
Hosting Process (vshost.exe) 宿主进程是VS的一个特性.可以提高调试的性能,可以进行部分信任调试(partial trust debugging),可以进行设计时表达式计算 ...
- [转]C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件讨论
原文出处:http://blog.163.com/chwei_sunshine/blog/static/19412628320125893656652/ pdb文件: 英文全称:Program Dat ...
随机推荐
- go break label goto label contiue lable
func main() { var i int fmt.Scanf("%d", &i) fmt.Println(i) if i%3 == 0 { goto LABLE1 } ...
- Mabatis三剑客分别是:mybatis-generator、mybatis-plugin、mybatis-pagehelper
本文用的是maven,idea15 Mabatis三剑客分别是:mybatis-generator.mybatis-plugin.mybatis-pagehelper 一.mybatis-genera ...
- bzoj千题计划301:bzoj4259: 残缺的字符串
https://www.lydsy.com/JudgeOnline/problem.php?id=4259 令通配符=0 f[i+m-1]=Σ (a[i+j]-b[m-1-j])^2 * a[i+j] ...
- Linux下删除命令 硬盘空间查看... 常用命令
(此命令请慎重使用) 使用rm -rf命令即可. 使用rm -rf 目录名字 命令即可 -r 就是向下递归,不管有多少级目录,一并删除-f 就是直接强行删除,不作任何提示的意思 (警告:不作任何 ...
- resultMap自定义某个javaBean的封装规则代码
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "- ...
- C# 读取Excel和DBF文件
//获excel中多个sheet中的数据 /// <summary> /// 读取导入Excel文件内容 /// </summary> /// <param name=& ...
- pygame设置text和image共同显示
下面介绍一下如何用pygame将text文本和图片一起绑定到视图 部分重点用不同颜色做了标记,希望对大家有帮助 代码块: %%writefile tranformtouxiang2.py import ...
- magelinux(0111)
Web Service 应用层:http, https 实现某类具体应用: 传输层协议:TCP, UDP, SCTP IANA: 0-1023:众所周知,永久地分配给固定的应用使用,特权端口: 102 ...
- WPS 表格筛选两列相同数据-完美-2017年11月1日更新
应用: 1.选出A列中的数据是否在B列中出现过: 2.筛选出某一批序号在一个表格里面的位置(整批找出) 3.其实还有其他很多应用,难描述出来... ... A列中有几百的名字,本人想帅选出B列中的名字 ...
- bootstrap3在IE8下导航不显示,自动识别成手机模式
想让bootstrap3兼容ie8,需要将html5shiv.js.respond.js还有bootstrap的所有css.js文件都放在本地服务器空间,不能用CDN. bootstrap所有css. ...