Link to home
Start Free TrialLog in
Avatar of TekiSreelakshmi
TekiSreelakshmi

asked on

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

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
Avatar of krunal_shah
krunal_shah

Avatar of Reza Rad
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

ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial