且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是加载系统配置属性.NET层次

更新时间:2022-11-03 09:42:04

  

的.NET配置的分层特性提供了一个很好的水平   的灵活性,允许特定用户或位置有自己的   配置设置。然而,这些配置设置不   在一个更具体的级别进行孤立和重复设置有   能够覆盖在一个不太具体的级别进行设置。由于可   见于图象,最具体的配置文件被合并到   更一般的,最具体的设置重写   不具体的。在埃克情况下,用户(或者更precise,当地   用户)设置是最具体,其次是漫游用户(共享   两个或两个以上的机器)之间,应用,最后机。

什么是加载系统配置属性.NET层次

我建议你阅读下面的文章,因为你的回答只是一个引用:

和有用的将是:

I have a general question, but I'll also explain why I'm asking so you can get a better idea of what I mean.

I have a dll that has a webservice url defined in Settings, and at runtime it uses Settings.Default to get the url from settings. However, none of our environments have a (dllName).dll.config file, and the specific setting is not defined in the (exeName).exe.config of the calling application. It's really clear that the default value isn't being used, because it's set to some internal IP address; yet this works in production where they don't have this setting defined in any .config file that I can find, and it's still hitting the correct webservice URL somehow. I need to know where the value is being loaded from in this case.

So my more broad question is, how does the hierarchy work for loading settings in .net? For example, does it look in machine.config first, then (exeName).exe.config, and the if it's a dll it would go to (dllName).dll.config? Where does it look first, and what order does it look in other places, and are there any other places I didn't mention that this config could be defined?

Also, for a DLL, if you have something defined in Settings, does that get embedded in the compiled dll as a default value, and is that used if the property isn't found in any other .config file?

The hierarchical nature of .NET configuration provides a great level of flexibility, allowing specific users or locations to have their own configuration settings. However, those configuration settings are not isolated and duplicate settings made at a more specific level have the ability to override settings made at a less specific level. As can be seen in picture, the most specific configuration files are merged into the less specific, with the most specific settings overriding the least specific. In the Exe context, User (or to be more precise, Local User) settings are most specific, followed by Roaming User (shared between two or more machines), Application and, finally, Machine.

I suggest you to read following article, because your answer is just a citation:

And usefull will be: