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

TekiSreelakshmi
TekiSreelakshmi used Ask the Experts™
on
Hi,

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
Comment
Watch Question

Do more with

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

Commented:
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.
reference:
http://msdn.microsoft.com/en-us/library/ms254494%28VS.80%29.aspx

Consultant, Trainer
Commented:
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