CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Apr 2005
    Posts
    43

    AppSettings returns null value

    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
    Last edited by sunsilk10; July 8th, 2008 at 09:58 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured