What is a .net hierarchy for loading system configuration properties

I have a general question, but I will also explain why I ask, so that you can better understand what I mean.

I have a dll that has the webservice url defined in the settings, and at runtime it uses Settings.Default to get the url from the settings. However, none of our environments has a file (dllName) .dll.config, and a specific parameter is not defined in (exeName) .exe.config of the calling application. It is really clear that the default value is not used because it sets some internal IP address; but this works in production where they do not have this parameter defined in any .config file that I can find, and it still ends up in the correct web service url. I need to know where the value is loaded from in this case.

So my broader question is: how does the hierarchy work to load settings into .net? For example, it looks first in machine.config, then (exeName) .exe.config, and if it is dll, will it refer to (dllName) .dll.config? Where does he look first and what order does he look in other places, and are there any other places, I did not mention that this config can be defined?

Also, for a DLL, if you have something defined in the settings, is it embedded in the compiled dll as the default value and used if the property is not found in any other .config file?

+4
source share
1 answer

The hierarchical nature of the .NET configuration provides an excellent level of flexibility, allowing specific users or locations to have their own configurations. However, these configuration settings are not isolated, and repeated settings made at a more specific level have the ability to override settings made at a less defined level. As can be shown in the figure, the most specific configuration files are combined into the less specific, with the most defined parameters, the least specific. In the context of Exe, the user (or, more precisely, the local User), and then the Roaming user (shared between two or more machines), Application, and, finally, Machine.

Config hierarchy and merging

I suggest you read the following article because your answer is just a quote:

And it will be useful:

+6
source

All Articles