I have a test project, with an App.config
that sets up default values for some settings. I want to override these settings at the local level so each developer can, for instance, use their own credentials.
In my App.config I have the following:
<appSettings file="Local.config">
<add key="Username" value="USERNAME"/>
<add key="Password" value="PASSWORD"/>
</appSettings>
in the Local.config (in the same directory) I have the following:
<appSettings>
<add key="Username" value="wayne"/>
<add key="Password" value="secret"/>
</appSettings>
When I run my test I expect that getting the value of Username would return "wayne" from the Local.config; instead, it's "USERNAME" from the App.config - it seems as though it's not actually detecting that I want to override settings in another file.
What am I doing wrong?
Add the App. config file to your project. After creating a . NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File item and then select Add.
I hate to ask, but are you sure the Local.config is being copied to the output directory?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With