1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 类库从自带的配置文件中获取信息(DLL文件 获取 DLL文件自带的配置信息) z...

类库从自带的配置文件中获取信息(DLL文件 获取 DLL文件自带的配置信息) z...

时间:2018-10-11 15:36:31

相关推荐

类库从自带的配置文件中获取信息(DLL文件 获取 DLL文件自带的配置信息)  z...

/shuaishifu/article/details/19602059

类库调用自身所带的配置文件中的配置信息,而不是读取应用程序所带的配置信息。代码如下:

private Configuration GetConfig(){//获取调用当前正在执行的方法的方法的 AssemblyAssembly assembly = Assembly.GetCallingAssembly();string path = string.Format("{0}.config", assembly.Location);if (File.Exists(path) == false){string msg = string.Format("{0}路径下的文件未找到 ", path);throw new FileNotFoundException(msg);}try{ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();configFile.ExeConfigFilename = path;Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);return config;}catch (Exception ex){throw new Exception(ex.Message);}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。