Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. app.config

app.config

Scheduled Pinned Locked Moved C#
xmlquestiondiscussionannouncementworkspace
5 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arkiboys
    wrote on last edited by
    #1

    Hi, I am using VS2008 and I am trying to access the appSetting value inside the app.config file. This GetSetting method returns null but there is value in the app.config file? Any thoughts please? This is what I am doing: string logFilePath = Util.GetSetting("LOGFILENAME"); public static string GetSetting(string val) { try { return ConfigurationSettings.AppSettings[val]; } catch (Exception ex) { return ""; } finally { } } -------------- App.Config file contains: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="LOGFILENAME" value="C:\Work\Developments\Services\LogFile\Log.txt" /> <add key="ERRORLOGFILENAME" value="C:\Work\Developments\Services\ErrorLogFile\Log.txt" /> <add key="PATHTOWATCH" value="C:\Work\Developments\" /> </appSettings> </configuration>

    S M 2 Replies Last reply
    0
    • A arkiboys

      Hi, I am using VS2008 and I am trying to access the appSetting value inside the app.config file. This GetSetting method returns null but there is value in the app.config file? Any thoughts please? This is what I am doing: string logFilePath = Util.GetSetting("LOGFILENAME"); public static string GetSetting(string val) { try { return ConfigurationSettings.AppSettings[val]; } catch (Exception ex) { return ""; } finally { } } -------------- App.Config file contains: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="LOGFILENAME" value="C:\Work\Developments\Services\LogFile\Log.txt" /> <add key="ERRORLOGFILENAME" value="C:\Work\Developments\Services\ErrorLogFile\Log.txt" /> <add key="PATHTOWATCH" value="C:\Work\Developments\" /> </appSettings> </configuration>

      S Offline
      S Offline
      SteveNY
      wrote on last edited by
      #2

      I use VS 2005 and this works: Properties.Settings.Default["name"]

      A A 2 Replies Last reply
      0
      • A arkiboys

        Hi, I am using VS2008 and I am trying to access the appSetting value inside the app.config file. This GetSetting method returns null but there is value in the app.config file? Any thoughts please? This is what I am doing: string logFilePath = Util.GetSetting("LOGFILENAME"); public static string GetSetting(string val) { try { return ConfigurationSettings.AppSettings[val]; } catch (Exception ex) { return ""; } finally { } } -------------- App.Config file contains: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="LOGFILENAME" value="C:\Work\Developments\Services\LogFile\Log.txt" /> <add key="ERRORLOGFILENAME" value="C:\Work\Developments\Services\ErrorLogFile\Log.txt" /> <add key="PATHTOWATCH" value="C:\Work\Developments\" /> </appSettings> </configuration>

        M Offline
        M Offline
        Marek Grzenkowicz
        wrote on last edited by
        #3

        Maybe this has something to do with this:

        [ObsoleteAttribute("This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings")]

        I know that obsolete doesn't mean it doesn't work but try to use the other method.

        1 Reply Last reply
        0
        • S SteveNY

          I use VS 2005 and this works: Properties.Settings.Default["name"]

          A Offline
          A Offline
          arkiboys
          wrote on last edited by
          #4

          I am using a windows service which has the app.config in it. That does not work.

          1 Reply Last reply
          0
          • S SteveNY

            I use VS 2005 and this works: Properties.Settings.Default["name"]

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            In VS2008 Properties.Settings.Default.yourpropertyname (intellisense should show yourpropertyname) works, and is (I believe) the currently recommended method.

            Bob Ashfield Consultants Ltd

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups