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作用区别的更多相关文章

  1. app.config *.exe.config 和*.vshost.exe.config基础学习

    一.问题描述 在使用config文件来保存一些参数,便于下次启动程序时自动加载上次设置的参数的功能时, 碰到个问题,vs2010下调试运行程序始终无法实现config记录上次参数值,而直接运行exe程 ...

  2. Debug目录、Release目录,bin目录、obj目录,vshost.exe.config文件、.exe.config文件分析【C#】

    原文地址:http://blog.csdn.net/itwit/article/details/6803338 今天写程序的时候,需要更改.exe.config文件中的引用的webservice地址, ...

  3. 宿主进程 [*.vshost.exe] & [*.vshost.exe.config]

    宿主进程 [*.vshost.exe] & [*.vshost.exe.config] pdb文件: 英文全称:Program Database File 中文全称:程序数据库 文件 Debu ...

  4. 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 ...

  5. Visual Studio 不生成.vshost.exe和.pdb文件的方法【转】

    Visual Studio 不生成.vshost.exe和.pdb文件的方法[转] 使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost ...

  6. [C#]Hosting Process (vshost.exe)

    写在前面 最近在群里,有朋友问起这个vshost.exe进程到底是什么?当时确实不知道是个什么东东,给人的感觉是,经常看到它,就是在启动一个项目的时候,经常看到它,就是没细研究它是啥玩意儿.既然遇到了 ...

  7. Visual Studio 不生成.vshost.exe和.pdb文件的方法

    使用Visual Studio编译工程时,默认设置下,即使选择了「Release」时也会生成扩展名为「.vshost.exe」和「.pdb」的文件. 一.先解释一下各个文件的作用: .pdb文件: 程 ...

  8. 宿主进程 vshost.exe

    Hosting Process (vshost.exe) 宿主进程是VS的一个特性.可以提高调试的性能,可以进行部分信任调试(partial trust debugging),可以进行设计时表达式计算 ...

  9. [转]C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件讨论

    原文出处:http://blog.163.com/chwei_sunshine/blog/static/19412628320125893656652/ pdb文件: 英文全称:Program Dat ...

随机推荐

  1. Spark记录-阿里巴巴开源工具DataX数据同步工具使用

    1.官网下载 下载地址:https://github.com/alibaba/DataX DataX 是阿里巴巴集团内被广泛使用的离线数据同步工具/平台,实现包括 MySQL.Oracle.SqlSe ...

  2. Css3实现常用的几种loading动画

    css实现loading动画非常方便,也非常实用 第一种 <!DOCTYPE html> <html lang="en"> <head> < ...

  3. MIPS架构上函数调用过程的堆栈和栈帧

    转载于CSDN:http://blog.csdn.net/do2jiang/article/details/5404566 在计算机科学中,Call stack是指存放某个程序的正在运行的函数的信息的 ...

  4. C++内存管理(转)http://www.cnblogs.com/qiubole/archive/2008/03/07/1094770.html

    [导语] 内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中获得了更好的性能,更大的自由,C++菜鸟的收获则是一遍一遍的检查代码和对C++的痛恨,但内存管理在C++中无处不 ...

  5. 第15月第22天 libz.dylib

    1. 3.在弹出的对话框中输入"cmd"+"shift"+"g" 4 4.输入/usr/lib https://jingyan.baidu. ...

  6. Centos7编译hadoop异常:Received fatal alert: handshake_failure

    保持网络畅通 或者 配置代理 能够访问cdh的仓库 https://repository.cloudera.com/artifactory/cloudera-repos/ 编译hadoop版本 had ...

  7. 2017-2018-2 20155303『网络对抗技术』Exp9:Web安全基础

    2017-2018-2 『网络对抗技术』Exp9:Web安全基础 --------CONTENTS-------- 一.基础问题回答 1.SQL注入攻击原理,如何防御? 2.XSS攻击的原理,如何防御 ...

  8. Informatic学习总结_day01

    1.forlder 必须open之后才出现  mapping的界面 2.Source Qualifer 3.小技巧 验证自己写的转换格式是否正确 提前过滤一些数据,informatica工具的本质也是 ...

  9. nginx入门三

    负载均衡 upstream upstream app_server { server 127.0.0.1:8000; server 192.168.2.134:80; server 47.xx.xx. ...

  10. 使用SSH远程登陆Linux

    ⒈SSH介绍 SSH(Secure Shell)由IETF的网络工作小组(NetWork Working Group)所制定,SSH是建立在应用层和传输层基础上的安全协议. SSH是目前较可靠,专为远 ...