.NET项目的app.config绑定
如何在app.config绑定?
How is the app.config binding in .Net?
比方说,如果我有一个应用程序项目引用一个类库项目。在code ConfigurationManager.AppSettings [MySetting]
在类库项目将读取从应用程序项目的App.config的价值。我的理解是否正确?
Let's say if I have an application project referencing a class library project. The code ConfigurationManager.AppSettings["MySetting"]
in the class library project will read the value from app.config from the application project. Is my understanding correct?
所以,怎么样,如果我们有2个类库项目,假设A和B,而A被引用B.因此将 ConfigurationManager.AppSettings [MySetting]
阅读从app.config中项目的值?
So how about if we have 2 class library project, let's say A and B while A is referencing B. So will ConfigurationManager.AppSettings["MySetting"]
read the value from app.config in project A?
在此先感谢。
在 ConfigurationManager中
会从由AppDomain中加载时,它加载的应用程序的配置文件中读取。这意味着,这是本地的组件应用程序配置加载,只有它的价值将通过 ConfigurationManager中
可用。
The ConfigurationManager
will read from the configuration file that was loaded by the AppDomain when it loaded the application. This means that the application configuration that was local to the assembly was loaded and only its values will be available via ConfigurationManager
.
您在您的两个假设是否正确,顺便说一句:)
You are correct in both of your assumptions, by the way :)