Not able to read the value from App.config file
-
I want to read the security key value from App.config file. Below is the procedure which I did : Create a new config file name as App.config In the App.config file: Added this: After that I did the following: System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); when i am debugging these, i find that the value of dimension is 0 which supposed to 1. since there is one key-value present in the App.config string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); Also it's throwing an exception stating “The key "SecurityKey" does not exist in the appSettings configuration section”.--which already present in the App.config. Also i tried with the second scenario: string key = System.Configuration.ConfigurationManager.AppSettings["SecurityKey"]; which giving me the key value null. Do i required to do some setting for reading the "SecurityKey" Value? Needs help! Thanks Sudhir Kumar Sudhir Kumar
-
I want to read the security key value from App.config file. Below is the procedure which I did : Create a new config file name as App.config In the App.config file: Added this: After that I did the following: System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); when i am debugging these, i find that the value of dimension is 0 which supposed to 1. since there is one key-value present in the App.config string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); Also it's throwing an exception stating “The key "SecurityKey" does not exist in the appSettings configuration section”.--which already present in the App.config. Also i tried with the second scenario: string key = System.Configuration.ConfigurationManager.AppSettings["SecurityKey"]; which giving me the key value null. Do i required to do some setting for reading the "SecurityKey" Value? Needs help! Thanks Sudhir Kumar Sudhir Kumar
Sudhir, Since I am unable to see your app.config file I am assuming this: C# Code: string key = System.Configuration.ConfigurationSettings.AppSettings["SecurityKey"].ToString(); This should work without any problem. Regards, Bhupesh.
-
I want to read the security key value from App.config file. Below is the procedure which I did : Create a new config file name as App.config In the App.config file: Added this: After that I did the following: System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader(); when i am debugging these, i find that the value of dimension is 0 which supposed to 1. since there is one key-value present in the App.config string key = (string)settingsReader.GetValue("SecurityKey", typeof(String)); Also it's throwing an exception stating “The key "SecurityKey" does not exist in the appSettings configuration section”.--which already present in the App.config. Also i tried with the second scenario: string key = System.Configuration.ConfigurationManager.AppSettings["SecurityKey"]; which giving me the key value null. Do i required to do some setting for reading the "SecurityKey" Value? Needs help! Thanks Sudhir Kumar Sudhir Kumar
Posting the question once and only in one forum will get you answers. Posting more than once and to different forums will get you ignored.
only two letters away from being an asset