获取指定DLL程序集Config 文件
2016-06-01 11:04
302 查看
/// <summary> /// 获取调用函数所在程序集的配置信息 /// </summary> /// <returns></returns> protected virtual Dictionary<string, string> GetConfigInfo() { Dictionary<string,string> dicInfo = new Dictionary<string,string> () ; ExeConfigurationFileMap map; map = new ExeConfigurationFileMap(); Assembly assembly = Assembly.GetCallingAssembly(); Uri uri = new Uri(Path.GetDirectoryName(assembly.CodeBase)); map.ExeConfigFilename = Path.Combine(uri.LocalPath, assembly.GetName().Name + ".dll.config"); if (!System.IO.File.Exists(map.ExeConfigFilename)) { WriteLog(string.Format("配置文件路径不存在,{0}", map.ExeConfigFilename)); return dicInfo; } KeyValueConfigurationCollection col = ConfigurationManager.OpenMappedExeConfiguration(map, 0).AppSettings.Settings; foreach (KeyValueConfigurationElement s in col) { dicInfo.Add(s.Key, s.Value); } return dicInfo; }
相关文章推荐
- 模拟一个弹出层
- 详细介绍java中的数据结构
- SQL Server 快捷键备忘
- MyEclipse 快捷键
- 利用Java的MyBatis框架获取MySQL中插入记录时的自增主键
- SQLServer XML 解析
- 去掉字符序列左边和右边的空格 trim()
- QuickWebApi:使用Lambada方式,完成对WebApi的开发和调用。
- 0601 新的冲刺
- 通过setContentView设置activity的不同样式
- node.js npm mysql 相关
- 基于pinctrl 和 devcice tree的SOC GPIO 使用
- volatile关键字解析
- dataTable转list C# asp.net
- git切换新的仓库地址
- IP地址,子网掩码,默认网关和DNS
- MetalSeed 's 网站收藏夹
- python中函数默认值使用注意点详解
- Boost1.62.0 + VS2015 配置
- 枚举