473,806 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ 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 ConfigurationSe ction. 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\My Project\src\Cor e.Tests\bin\Deb ug\MyProject.Co re.Tests.dll.te mp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None); is
how you get hold of it.

Thanks for helping - Eric

CODE
------
[Test]
public void RemoveASection( ) {
var config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
var groups = config.Sections ;
Console.WriteLi ne(config.FileP ath);

if
(config.Section s[DomainObjectMap pingConstants.C onfigurationSec tionName] !=
null) {
var section =
config.Sections[DomainObjectMap pingConstants.C onfigurationSec tionName] ;
Assert.That(sec tion.SectionInf ormation.Name,
Is.EqualTo(Doma inObjectMapping Constants.Confi gurationSection Name));
groups.Remove(s ection.SectionI nformation.Name );
config.Save(Con figurationSaveM ode.Full);
Assert.That(con fig.Sections[DomainObjectMap pingConstants.C onfigurationSec tionName]
== null);
}
}

APP.CONFIG
---------------
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
------------
<section name="domainObj ectMappingsConf iguration"
type="Core.Doma in.FactoryFrame work.Configurat ion.DomainMapSe ttings,
Core, Version=1.0.0.0 , Culture=neutral , PublicKeyToken= null"/>
------------
</configSections>

</configuration>
Aug 3 '08 #1
3 2343
Eric submitted this idea :
I'm trying to manipulae my app.config file. Below is code to test that I can
remove a ConfigurationSe ction. 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\My Project\src\Cor e.Tests\bin\Deb ug\MyProject.Co re.Tests.dll.te mp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.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*********@sp amgourmet.comwr ote in message
news:Od******** ******@TK2MSFTN GP05.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 ConfigurationSe ction. 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\M yProject\src\Co re.Tests\bin\De bug\MyProject.C ore.Tests.dll.t emp.config>
isn't app.config but I've seen a couple of places that say that
ConfigurationM anager.OpenExeC onfiguration(Co nfigurationUser Level.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*********@sp amgourmet.comwr ote in message
news:Od******** ******@TK2MSFTN GP05.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 ConfigurationSe ction. 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\C ore.Tests\bin\D ebug\MyProject. Core.Tests.dll. temp.config>
isn't app.config but I've seen a couple of places that say that
Configuration Manager.OpenExe Configuration(C onfigurationUse rLevel.None); is
how you get hold of it.

The file that is named app.config in your VS project is renamed to
<assemblyoutpu t>.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
7077
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 an example of what I'm trying to achieve: I tried a test by creating a simple app Test.exe that has some basic settings made available to it in the runtime file Test.exe.config.
1
2146
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 bug or is it by design. Do we know why microsoft do not supply a method to write values to the web.config file. Thank you to anyone who can give me any clues to this problem. Regards,
3
2236
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 the app. How can I finally convince my exe.config file to keep straight?
5
3442
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 is: can the changes made by the user to the settings values be saved back to "app.config" so that when the application is launched tomorrow, the updated values are used? Since the original app.config settings are loaded to...
17
3257
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 production. I'm in the process of writing a site that will have lots of traffic so I'm trying to save resources everyplace that I can. My question is - do the web.config app settings get loaded once when the
1
3281
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 exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
1
2605
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 exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
1
5143
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 that users will be working with 99% of the time, the other is a seperate "maintenance" executable. The connection string is stored via My.Settings (encrypted of course). The problem is that obviously with 2 different .exe there are 2 seperate...
3
11653
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 fact saved. All is good! However, When I go to the application Folder application.exe.config and open the file, the file has my original design time settings for
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.