views:

80

answers:

1

How is the app.config binding in .Net?

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?

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?

Thanks in advance.

+2  A: 

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 :)

Andrew Hare
I got it, thanks.
Ted Lee