I have following app.config. I would like save into ConnectionString key value - my text from serialized xml.
Private Shared strcon As String = New AppSettingsReader().GetValue("ConnectionString", GetType(System.String)).ToString()
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value=""/>
</appSettings>
<system.diagnostics>
<sources>
...
So far i got this code but i am receiving error: "Object reference not set to an instance of an object."
on the line: config.AppSettings.Settings("ConnectionString").Value = "myconn"
' Get the configuration file.
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
' Update the setting.
config.AppSettings.Settings("ConnectionString").Value = "myconn"
' Save the configuration file.
config.Save(ConfigurationSaveMode.Modified)
' Force a reload of the changed section.
ConfigurationManager.RefreshSection("appSettings")