/// <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;
        }

 

相关文章:

  • 2021-09-04
  • 2021-12-13
  • 2021-09-08
  • 2022-01-11
  • 2021-06-16
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-07-18
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
相关资源
相似解决方案