467,104 Members | 1,055 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

Configuration.Save() does not work?

Hello All: I have implemented a custom configuration section in my
app.config file as follows:

<configSections>
<section name="AdminUIConfig"
type="TestMgr.UIConfigSection,TestMgr"/>
</configSections>

<AdminUIConfig name="Admin" caption="Administrator"
captionLC="administrator">
<lookupLayouts>
<lookupLayout name="c1" caption="Administrator" imageIndex="0"
property="FullName" />
<lookupLayout name="c2" caption="Email Address"
property="EmailAddress" />
<lookupLayout name="c3" caption="Insert By" property="InsertBy" />
<lookupLayout name="c4" caption="Insert Date" property="InsertDate"
/>
<lookupLayout name="c5" caption="Update By" property="UpdateBy" />
<lookupLayout name="c6" caption="Update Date" property="UpdateDate"
/>
</lookupLayouts>
</AdminUIConfig>

I can read the configuration properties from my custom section without
issue. When I modify one of the properties in this section programmatically
and save the configuration file nothing seems to happen? The configuration
remains changed while the application is open but when the application
restarts the changes I saved are not available?

I modify and save a property for my custom section as follows:

Dim c As Configuration
Dim s As UIConfigSection
c =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
s = c.GetSection("AdminUIConfig")
s.captionLC = "MODIFIED!"
s.SectionInformation.ForceSave = True
c.Save(ConfigurationSaveMode.Modified)

AM I MISSING SOMETHING?

Thank you,
Shannon Richards
BBA, AIT, MCP

Mar 31 '07 #1
  • viewed: 14640
Share:
1 Reply
All: As it turns out, the issue is not with the code as outlined below...It
is an issue as a result of running the application in the Visual Studio IDE
at design time!

http://msdn2.microsoft.com/en-us/lib...31(VS.80).aspx

Basically Visual Studio virtually hosts the application and as a result
utilizes some temporary host files. If you look in the bin directory you'll
notice a myApp.vshost.exe.Config file. When saving configuration changes it
is actually this vshost file that is being updated not the myApp.exe.Config
file. If you open the myApp.vshost.exe.Config while running your project in
the IDE you'll see your configuration changes taking effect.

Running the application as a compiled executable outside the IDE you will
notice it is indeed the myApp.exe.Config that is getting updated.

Shannon Richards
BBA, AIT, MCP

"Shannon Richards" <sr**********@hotmail.comwrote in message
news:91**********************************@microsof t.com...
Hello All: I have implemented a custom configuration section in my
app.config file as follows:

<configSections>
<section name="AdminUIConfig"
type="TestMgr.UIConfigSection,TestMgr"/>
</configSections>

<AdminUIConfig name="Admin" caption="Administrator"
captionLC="administrator">
<lookupLayouts>
<lookupLayout name="c1" caption="Administrator" imageIndex="0"
property="FullName" />
<lookupLayout name="c2" caption="Email Address"
property="EmailAddress" />
<lookupLayout name="c3" caption="Insert By" property="InsertBy" />
<lookupLayout name="c4" caption="Insert Date" property="InsertDate"
/>
<lookupLayout name="c5" caption="Update By" property="UpdateBy" />
<lookupLayout name="c6" caption="Update Date" property="UpdateDate"
/>
</lookupLayouts>
</AdminUIConfig>

I can read the configuration properties from my custom section without
issue. When I modify one of the properties in this section
programmatically and save the configuration file nothing seems to happen?
The configuration remains changed while the application is open but when
the application restarts the changes I saved are not available?

I modify and save a property for my custom section as follows:

Dim c As Configuration
Dim s As UIConfigSection
c =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None)
s = c.GetSection("AdminUIConfig")
s.captionLC = "MODIFIED!"
s.SectionInformation.ForceSave = True
c.Save(ConfigurationSaveMode.Modified)

AM I MISSING SOMETHING?

Thank you,
Shannon Richards
BBA, AIT, MCP
Mar 31 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by sebsauvage | last post: by
7 posts views Thread by Steven Cliff | last post: by
6 posts views Thread by Jeff Hegedus | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.