Configuration file for application
-
Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga
-
Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga
-
Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga
You shouldn't need to create an
AppSettingsReader
for the configuration file. There is anAppSettings
property in theConfigurationSettings
class which is aNameValueCollection
, this collection contains all of the keys in the appSettings node of the XML file. Try that and see if it helps. James "Java is free - and worth every penny." - Christian Graus -
You shouldn't need to create an
AppSettingsReader
for the configuration file. There is anAppSettings
property in theConfigurationSettings
class which is aNameValueCollection
, this collection contains all of the keys in the appSettings node of the XML file. Try that and see if it helps. James "Java is free - and worth every penny." - Christian Graus