类库从自带的配置文件中获取信息(DLL文件 获取 DLL文件自带的配置信息) z
2014-12-21 19:02
309 查看
http://blog.csdn.net/shuaishifu/article/details/19602059
类库调用自身所带的配置文件中的配置信息,而不是读取应用程序所带的配置信息。代码如下:
private Configuration GetConfig() { //获取调用当前正在执行的方法的方法的 Assembly Assembly 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); } }
相关文章推荐
- C# 类库从自带的配置文件中获取信息(DLL文件 获取 DLL文件自带的配置信息)
- .net类库获取当前类库的配置(dll的app.config读写)
- 类项目中的配置文件app.config在打包安装后的信息获取的问题
- 通过ResourceBoudle获取配置文件信息
- Eclipse下的Java工程用JavaProject对象获取配置信息(不用读取配置文件)
- windows 批处理按照配置信息从主机不同目录获取文件保存在windows
- 获取配置文件中configSections的配置信息!
- 获取配置文件中configSections的配置信息!-.
- android 获取配置文件信息
- Spring配置文件中使用PropertyPlaceholderConfigurer配置获取jdbc的配置信息
- 利用jConfig获取xml文件中的配置信息
- 类项目中的配置文件app.config在打包安装后的信息获取的问题【转】
- C#类库DLL配置文件
- 读取应用程序/类库配置文件(比如***.dll.config)的方法小结
- 获取配置文件中configSections的配置信息http://www.linuxmine.com/38234.html
- 通过silktest调用c#写的工具获取dll文件信息的方法
- 类项目中的配置文件app.config在打包安装后的信息获取的问题
- C# dll类库如何设置配置文件?
- Linux下获取配置文件信息
- Java 获取到配置文件信息