473,414 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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
1 15461
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sebsauvage | last post by:
Hello. In one of my programs ( http://sebsauvage.net/python/webgobbler/ ), I have a global dictionnary containing the whole program configuration. Sample follows: CONFIG = {...
2
by: Al Repasky | last post by:
The program I have written with VB/NET 2003 has a Myapp.exe.config file that I did not know I would be creating. My program using an Access db and can not find the DB file after building the...
7
by: MrNobody | last post by:
I was a Java developer so I'm used to using property files as a means to keep configuration settings for my apps. I'm wondering what options are there with ..NET? Some settings I want to include...
0
by: SR | last post by:
I am trying to use the Configuration object provided with the .NET 2.0 framework. I see that when I call the Save function it does update the <application>.exe.config file. However, when I close...
7
by: Steven Cliff | last post by:
I have started to use the new Enterprise Library (Jan 06) and have set up a skeleton project using the DAAB. This all seems to work fine apart from when I come to secure the app.config file via...
6
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
0
by: michael1778 | last post by:
I have having trouble to get the following code (related to custom configuration .net 2.0) to work. Can anyone please help? Custom config file: <?xml version="1.0" encoding="utf-8"?>...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi, thanks, mister The code string rutaConfig = tbRutaConfigServicioBase.Text; '// Map to the application configuration file. ExeConfigurationFileMap configFile = New...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi misters, I have an app.config (UTF-8 format file). I create an application winforms for changes and save configuration programatically. When I save changes the format file changes to ANSI ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.