views:

362

answers:

3

In my app.config i got something like:

<appSettings configSource="AppSettings.config"/>

I would have expected the application to read the settings dynamically from AppSettings.config but i doesn't...

Am i wrong here?

A: 

You are using the wrong attribute, use the file attribute to reference an external configuration file:

<appSettings file="AppSettings.config"/>
Andrew Hare
ok, iam trying this.. but i can't use file for the connectionStrings.. what di i do with them?
David
@Andrew, why do you think configSource is the wrong attribute? Has it been deprecated or something?
Charles Bretana
+1  A: 

app.config is read once at startup. Re-reading each time a config value is referenced could be a big performance hit. Besides, there are some entries like dependencies that it wouldn't make sense to change at runtime.

ctford
A: 

The Setting is correct. But as ctford said, this is only read once, when the application starts up... Is the file in the same folder as the application executable is being loaded from ? Also, in Visual Studio, where you have the file stored, right click on it, and verify that you have the Visual Studio File property "Copy to Output Directory" set appropriately. For files like this, the default is "Do Not Copy" and then the file will, duh, not be there when the app runs and looks for it...

Charles Bretana