Configurationmanager.Connectionstrings is retrieving values from machine.config instead of app.config

TekiSreelakshmi used Ask the Experts™

I have a class project among others inside a blank VS project. I have added an app.config file to this project and am using Configuration.Configurationmanager.Connectionstrings to retrieve connection strings from it. However it is retrieving values from machine.config instead of app.config. Any idea why this is happening and how do I change it?

Thanks in advance
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Reza RadConsultant, Trainer

When retrieving connection strings by provider name from the app.config file in a Windows application, the connection strings in machine.config get loaded first, and then the entries from app.config. Adding clear immediately after the connectionStrings element removes all inherited references from the data structure in memory, so that only the connection strings defined in the local app.config file are considered.

Consultant, Trainer
add the <clear /> before connectionstring as showed in the link i referred

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial