Link to home
Start Free TrialLog in
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMPFlag for United States of America

asked on

URGENT - C# Windows App Config File

Hi All,

For Some reason my windows app isn't pulling the config settings and it's driving me nuts.  
Added the config through solution explorer.  Named it test.config

My Config File:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <appSettings>
   <add key="dbConnString" value="server=127.0.0.1;uid=sa;pwd=;database=Northwind" />
 </appSettings>
</configuration>

Accessing in the code like this:
private String dbConnString = ConfigurationSettings.AppSettings ["dbConnString"];


Am I missing something?  I haven't touched the assembly at all, do I need to add it to GAC or anything before the config will take effect?
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

http://www.c-sharpcorner.com/Code/2002/April/XMLConfigInWinForms.asp

note in particular

"The configuration file should be in the same directory as the application. The name of the configuration file should have the same name as the application with .config at the end. For example, an application called Watcher.exe should have a configuration file called Watcher.exe.config."
Avatar of Kyle Abrahams, PMP

ASKER

anyway to make it compile and put it in the debug bin then?
Also just tried it that way (to try to brute force it)  It didn't work there either.

your config file isn't "compiled".

other key part is the name of the file.

Greg
you said test.config....

for test.exe ... it should be named test.exe.config

Cheers,

Greg
I switched  it to test.exe and test.exe.config.   Still no luck.

ASKER CERTIFIED SOLUTION
Avatar of vinhnl
vinhnl

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
SOLUTION
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
Solution presented:

I deleted ALL config files.  Created 1 new config named app.config.  It now works :-).  Thanks very much for your help.