Hi all,
I've been scouring the internet for help with this problem and every
occurance i've seen reconstructs the problem but no one seems to have a
solution. Hoping that you guys can help me.
I have a vb.net windows forms project that is using a app.config file.
the contents of the app.config is staggered. see a snippet below:
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
<!-- tell .NET Framework to ignore CLR sections -->
<section name="frisbee"
type="System.Co nfiguration.Nam eValueFileSecti onHandler, System,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
<section name="frmBatchi ng"
type="System.Co nfiguration.Nam eValueFileSecti onHandler, System,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
<section name="frmFilter ing"
type="System.Co nfiguration.Nam eValueFileSecti onHandler, System,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
<section name="frmConfig "
type="System.Co nfiguration.Nam eValueFileSecti onHandler, System,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
<section name="frmSuppor ting"
type="System.Co nfiguration.Nam eValueFileSecti onHandler, System,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
</configSections>
<frisbee>
<add key="intErrorLo gtype" value="1" />
<add key="EventLogKe yName" value="FRISBEE" />
<add key="SQLDBConnS tring" value="" />
<add key="sys_DBChec k" value="usp_Chec kSQLConnection" />
<add key="Maximised" value="true" />
</frisbee>
<frmBatching>
<add key="height" value="" />
<add key="width" value="" />
<add key="top-left-position" value="" />
<add key="ImgDir" value="" />
<add key="BatchDir" value="" />
<add key="ImgInBatch " value="" />
<add key="BatchNo" value="" />
<add key="Maximised" value="true" />
</frmBatching>
Now to read values out of this staggered app.config file i use the
specialised.nam evaluecollectio n in the following manner
Dim objConfigNV As New Specialized.Nam eValueCollectio n
Dim strConfigValue As String = Convert.ToStrin g(vbNullString)
objConfigNV = CType(Configura tionSettings.Ge tConfig(strIDic Name),
Specialized.Nam eValueCollectio n)
strConfigValue = Convert.ToStrin g(objConfigNV(s trKeyName))
And this works fine.
Now.. the problem..
to write a value back to the app.config file using the same
Specialized.Nam evalueCollectio n in the following manner:
'initialise collection object of app.config
Dim objNameValue As New Specialized.Nam eValueCollectio n
'app.ocnfig is staggered. this gets the relevant sectoin on
file
objNameValue =
CType(Configura tionSettings.Ge tConfig("frmSup porting"),
Specialized.Nam eValueCollectio n)
'this sets the the new value of a key
objNameValue(st rKey) = strValue
Generates an exception: Collection is read-only
Does ANYONE have any ideas how to create an instance of a
NameValueCollec tion that is not read-only so that I can write back to my
app.config file.
Any help on this would be greatly appreciated.
Kerr
*** Sent via Developersdex http://www.developersdex.com ***