sunsilk10
July 8th, 2008, 09:56 AM
Hi, I have come across a rather strange problem, seems quite straightforward, but I can't figure out what is wrong here:
I have a C# program with an application configuration file (app.config added in Visual Studio 2005). The contents of app.config are:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="KeyName" value="KeyValue"/>
</appSettings >
</configuration>
Now when I try to read the values from my config file
string sTemplateFile = ConfigurationManager.AppSettings.Get("KeyName");
or
string sTemplateFile = ConfigurationManager.AppSettings["KeyName"];
it returns null value
I have created the config file using the VS template. I can see the config file in my debug folder also.
Can anyone shed some light what is going on?
Thanks
I have a C# program with an application configuration file (app.config added in Visual Studio 2005). The contents of app.config are:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="KeyName" value="KeyValue"/>
</appSettings >
</configuration>
Now when I try to read the values from my config file
string sTemplateFile = ConfigurationManager.AppSettings.Get("KeyName");
or
string sTemplateFile = ConfigurationManager.AppSettings["KeyName"];
it returns null value
I have created the config file using the VS template. I can see the config file in my debug folder also.
Can anyone shed some light what is going on?
Thanks