473,473 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

app.config changes not being saved

I'm trying to manipulae my app.config file. Below is code to test that I can
remove a ConfigurationSection. It looks like its working, but the app.config
file is not changed when I look at it after.

I think it has something to do with the file path; the .FilePath returned
<C:\Projects\MyProject\src\Core.Tests\bin\Debug\My Project.Core.Tests.dll.temp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None); is
how you get hold of it.

Thanks for helping - Eric

CODE
------
[Test]
public void RemoveASection() {
var config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
var groups = config.Sections;
Console.WriteLine(config.FilePath);

if
(config.Sections[DomainObjectMappingConstants.ConfigurationSectionN ame] !=
null) {
var section =
config.Sections[DomainObjectMappingConstants.ConfigurationSectionN ame] ;
Assert.That(section.SectionInformation.Name,
Is.EqualTo(DomainObjectMappingConstants.Configurat ionSectionName));
groups.Remove(section.SectionInformation.Name);
config.Save(ConfigurationSaveMode.Full);
Assert.That(config.Sections[DomainObjectMappingConstants.ConfigurationSectionN ame]
== null);
}
}

APP.CONFIG
---------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
------------
<section name="domainObjectMappingsConfiguration"
type="Core.Domain.FactoryFramework.Configuration.D omainMapSettings,
Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
------------
</configSections>

</configuration>
Aug 3 '08 #1
3 2326
Eric submitted this idea :
I'm trying to manipulae my app.config file. Below is code to test that I can
remove a ConfigurationSection. It looks like its working, but the app.config
file is not changed when I look at it after.

I think it has something to do with the file path; the .FilePath returned
<C:\Projects\MyProject\src\Core.Tests\bin\Debug\My Project.Core.Tests.dll.temp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None); is
how you get hold of it.
The file that is named app.config in your VS project is renamed to
<assemblyoutput>.config and copied to the build-directory when you
compile the project. I don't know where the ".temp" part is coming
from.

Did you read *that* file after the test was run, or your original
"app.config" file? Any changes will not be copied back...

Hans Kesting
Aug 4 '08 #2
I looked at (read) the original app.config file. Isn't that where changes
should be?
"Hans Kesting" <ne*********@spamgourmet.comwrote in message
news:Od**************@TK2MSFTNGP05.phx.gbl...
Eric submitted this idea :
>I'm trying to manipulae my app.config file. Below is code to test that I
can remove a ConfigurationSection. It looks like its working, but the
app.config file is not changed when I look at it after.

I think it has something to do with the file path; the .FilePath returned
<C:\Projects\MyProject\src\Core.Tests\bin\Debug\M yProject.Core.Tests.dll.temp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationManager.OpenExeConfiguration(Configu rationUserLevel.None);
is how you get hold of it.

The file that is named app.config in your VS project is renamed to
<assemblyoutput>.config and copied to the build-directory when you compile
the project. I don't know where the ".temp" part is coming from.

Did you read *that* file after the test was run, or your original
"app.config" file? Any changes will not be copied back...

Hans Kesting


Aug 5 '08 #3
Eric formulated on dinsdag :
I looked at (read) the original app.config file. Isn't that where changes
should be?
No, that file is copied to the build directory and renamed. See your
returned "FilePath" - do you see your changes in *that* file?
This is identical to the "live" situation: there you also don't have
that "app.config" anywhere, just the renamed version: full name of the
project output (including a .dll or .exe extension) plus the (extra)
..config extension.

Hans Kesting
>
"Hans Kesting" <ne*********@spamgourmet.comwrote in message
news:Od**************@TK2MSFTNGP05.phx.gbl...
>Eric submitted this idea :
>>I'm trying to manipulae my app.config file. Below is code to test that I
can remove a ConfigurationSection. It looks like its working, but the
app.config file is not changed when I look at it after.

I think it has something to do with the file path; the .FilePath returned
<C:\Projects\MyProject\src\Core.Tests\bin\Debug\ MyProject.Core.Tests.dll.temp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationManager.OpenExeConfiguration(Config urationUserLevel.None); is
how you get hold of it.

The file that is named app.config in your VS project is renamed to
<assemblyoutput>.config and copied to the build-directory when you compile
the project. I don't know where the ".temp" part is coming from.

Did you read *that* file after the test was run, or your original
"app.config" file? Any changes will not be copied back...

Hans Kesting


Aug 5 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Danny | last post by:
Hello, I was wondering if anyone knew if it was possible to make changes to an application's App.config file at runtime and then be able to access those changes immediately. The following is...
1
by: Matt | last post by:
Hi, I was wondering if anyone can tell me why dynamically updating the web.config file causes ASP.NET worker process to recycle and detroy all session states including variables. Is this a known...
3
by: Lisa | last post by:
Suddenly, the encoding in my exe.config file changes from UTF-8 to Windows-1252 every time I try to debug my winform app. This causes the old application configuration error when I try to debug...
5
by: Dean Slindee | last post by:
I store several application settings in the project's "app.config" file. I also have a form that reads these values and displays them in a listview so that the user can adjust them. My question...
17
by: Fred Nelson | last post by:
Hi: I have written several web applications that obtain their connection strings from the web.config file. This is very easy to use and it makes it easy to move an app from development into...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Matt F | last post by:
Two of the projects in my solution that both need to use a common user.config file. This is a data application - the executable that is created with the first project is the primary executable...
3
by: DaBrain | last post by:
I have a program that uses settings. When I save my settings they are saved: Properties.Settings.Default.Save(); when I restart the application, my settings are present, the changes are in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.