- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
OpenExeConfiguration 有 2 个重载:
OpenMappedExeConfiguration 只有 1 个原型(prototype):
似乎 (2) 和 (3) 都可以用来打开特定的配置文件,而不是默认的 app.config 文件。
那么它们有什么区别呢?什么时候使用哪个?
为什么我们在(1)和(2)中将UserLevel和Config File Location分开,而在(3)中将它们合并?
感谢您的任何回复。
我知道微软总是喜欢以不止一种方式做事。但它应该这样做是有原因的。任何人都知道我的问题的原因吗?我们需要赏金 ;) 吗?
最佳答案
差异在最终的 .NET 配置资源中进行了解释 - Cracking the Mysteries of .NET 2.0 Configuration :
OpenExeConfiguration(字符串)
will append ".config" to the filename you provide and load that configuration file. It's important to note that OpenExeConfiguration(string exePath) is a very misleading method, as the filename does not have to be the filename of the .exe that is running [...] By providing a filename other than the EXE filename, an alternate *.config file can be opened.
OpenExeConfiguration (ConfigurationUserLevel)
The second method, OpenExeConfiguration(ConfigurationUserLevel level) will load the appropriate configuration file for the specified configuration level. Configuration levels, available in the Exe context, allow you to specify whether you want exe, roaming user, or local user configuration [...] Remember that configuration is hierarchical and merged. When requesting roaming or local user configuration, that level up through machine.config are merged, resulting in the complete configuration accessible by your application for the given user level.
OpenMappedExeConfiguration()、OpenMappedMachineConfiguration()
Unlike the OpenExeConfiguration() methods, which make several assumptions about where your configuration files reside, OpenMappedExeConfiguration() and OpenMappedMachineConfiguration() allow you to explicitly specify where your *.config files reside on disk. Using these methods, you can load an alternate machine.config, load User.config files from the locations of your own choosing (vs. letting the .NET framework decide on some convoluted path), etc. When accessing machine.config, a custom version is not required, OpenMachineConfiguration() should be used instead.
关于c# - OpenMappedExeConfiguration 与 OpenExeConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3912727/
我有这个被加载到第三方系统中的类库。多年来我一直使用自定义配置并通过 ConfigurationManager.OpenMappedExeConfiguration() 访问它们,因为这始终允许我将配
OpenExeConfiguration 有 2 个重载: ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel) ---
我正在为一个 win 表单应用程序对我的配置文件进行单元测试。在 LocalTestRun.testrunconfig 中,我将其设置为复制 app.config。我在测试运行时检查了 Envir
首先,让我提前为这个超长的问题道歉——感谢所有坚持到最后的人! 我有一个 C#/.NET 3.5 类库,它没有安装在 GAC 中,因为该类库是另一个程序 (ArcMap.exe) 的插件。该程序实际上
我是一名优秀的程序员,十分优秀!