app.config
-
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>
-
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>
-
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>
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.