471,347 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

need help with reading from app config file

Hi,

I am trying to read from my application config file and keep getting
null.

Here is my config file
My application is called SampleApp.exe

I named the config file: SampleApp.exe.config
Inside the config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="key1" value = "test1"/>
</appSettings>
</configuration>
In my C# code, I have the following

string strTest1 =
System.Configuration.ConfigurationSettings.AppSett ings["key1"];

I keep getting null value for strTest1.

I tried placing the SampleApp.exe.config inside the debug bin folder. I
also tried creating a shortcut of the config and placing that shortcut
inside the bin/debug folder, but the same results.
Any help is appreciated.

Thanks,

Rage

Jan 25 '06 #1
1 1613
comic_rage,
When you add an app.config file to your PROJECT, at build time this is
converted to "yourappname.exe.config" and it is deposited right next to the
built executable in either the debug or the release folder, depending on the
build type.
Whatever settings you put into it in design mode in the IDE will be
persisted to the "built" version of the file.
When an application EXE starts, it checks to see if there is a corresponding
..config file, loads and processes it.
You do NOT need to "name" the config file. Leave it as "app.config" in your
project tree and it will be taken care of during the buiild.

Hope that helps!
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"co********@yahoo.com" wrote:
Hi,

I am trying to read from my application config file and keep getting
null.

Here is my config file
My application is called SampleApp.exe

I named the config file: SampleApp.exe.config
Inside the config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="key1" value = "test1"/>
</appSettings>
</configuration>
In my C# code, I have the following

string strTest1 =
System.Configuration.ConfigurationSettings.AppSett ings["key1"];

I keep getting null value for strTest1.

I tried placing the SampleApp.exe.config inside the debug bin folder. I
also tried creating a shortcut of the config and placing that shortcut
inside the bin/debug folder, but the same results.
Any help is appreciated.

Thanks,

Rage

Jan 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Michael Probst | last post: by
3 posts views Thread by Winston Nimchan | last post: by
22 posts views Thread by James Stroud | last post: by
1 post views Thread by M Irfan | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.