什么是加载系统配置属性

什么是加载系统配置属性

本文介绍了什么是加载系统配置属性.NET层次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个一般性的问题,但我会也解释了我为什么要问这样你就可以更好地理解我的意思。

我有一个DLL,在设置中定义的Web服务的URL,并在运行时,它使用Settings.Default来从设置的URL。然而,没有我们的环境中的具有(DLLNAME).dll.config文件,所述特定设置未在调用应用程序的(EXENAME).exe.config限定。这真是显然,在不使用默认值,因为它设置一些内部的IP地址;但这种工作在生产,他们没有任何config文件,我可以找到定义此设置,它仍然击中了正确的Web服务URL莫名其妙。我需要知道的价值正在从在这种情况下加载。

所以,我更广泛的问题是,如何在.NET中加载设置层次的工作?例如,它看起来在machine.config中,再(EXENAME).exe.config,而如果它是一个dll它会去(DLLNAME).dll.config?它在哪里看第一个,它看起来在其他地方什么样的顺序,以及是否有任何其他地方我没有提到这个配置可以被定义?

另外,对于一个DLL,如果你有一些在设置中定义,这是否得到嵌入在编译DLL作为一个默认值,并且是使用,如果没有在任何其他的config文件中找到的属性?

解决方案

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

和有用的将是:

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?

解决方案

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

And usefull will be:

这篇关于什么是加载系统配置属性.NET层次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:53