473,322 Members | 1,523 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,322 software developers and data experts.

ConfigurationManager

I don't get the ConfigurationManager object. All I want to do is store my
application settings and retrieve them on the next run.

I instantiate the Configuration:

static private Configuration m_Config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
I check if my setting exists:

try //kolla om Settings finns och skapa dem om de inte finns

{ string testSetting =
Utils.GlobalVars.FoBSettings.AppSettings.Settings["LokalServer"].Value; }

catch

{

m_Config.AppSettings.Settings.Add("LokalServer", "");

}
I change it if needed:

m_Config.AppSettings.Settings["LokalServer"].Value = "MyTestServer");
And I save the entire configuration file:

m_Config.Save(System.Configuration.ConfigurationSa veMode.Full);
Still, the next time I run the application, the LokalServer setting is Null
in AppSettings. Nothing is saved.

Why? What am I missing.
Cheers,
Johnny J.
Apr 20 '07 #1
2 4134
I just found out that it works when I run the exe file directly, but NOT
when I run the program from the IDE - how can that be?

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
>I don't get the ConfigurationManager object. All I want to do is store my
application settings and retrieve them on the next run.

I instantiate the Configuration:

static private Configuration m_Config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
I check if my setting exists:

try //kolla om Settings finns och skapa dem om de inte finns

{ string testSetting =
Utils.GlobalVars.FoBSettings.AppSettings.Settings["LokalServer"].Value; }

catch

{

m_Config.AppSettings.Settings.Add("LokalServer", "");

}
I change it if needed:

m_Config.AppSettings.Settings["LokalServer"].Value = "MyTestServer");
And I save the entire configuration file:

m_Config.Save(System.Configuration.ConfigurationSa veMode.Full);
Still, the next time I run the application, the LokalServer setting is
Null in AppSettings. Nothing is saved.

Why? What am I missing.
Cheers,
Johnny J.


Apr 20 '07 #2
Well, when you run from the IDE, or do a build, it is probably copying
over the app.config file in your project every time, which is causing the
values to reset.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
>I just found out that it works when I run the exe file directly, but NOT
when I run the program from the IDE - how can that be?

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
>>I don't get the ConfigurationManager object. All I want to do is store my
application settings and retrieve them on the next run.

I instantiate the Configuration:

static private Configuration m_Config =
ConfigurationManager.OpenExeConfiguration(Configu rationUserLevel.None);
I check if my setting exists:

try //kolla om Settings finns och skapa dem om de inte finns

{ string testSetting =
Utils.GlobalVars.FoBSettings.AppSettings.Settin gs["LokalServer"].Value; }

catch

{

m_Config.AppSettings.Settings.Add("LokalServer" , "");

}
I change it if needed:

m_Config.AppSettings.Settings["LokalServer"].Value = "MyTestServer");
And I save the entire configuration file:

m_Config.Save(System.Configuration.ConfigurationS aveMode.Full);
Still, the next time I run the application, the LokalServer setting is
Null in AppSettings. Nothing is saved.

Why? What am I missing.
Cheers,
Johnny J.



Apr 20 '07 #3

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

Similar topics

4
by: Michael Debus | last post by:
Hi, I try to read a value from app.config file using this code: string s=System.Configuration.ConfigurationManager.AppSettings.ToString(); I got the compiler error: Error 1 The type or...
2
by: Myo Zaw | last post by:
hi, can i use configurationmanager in .net 2.0 windows form. cause i have an app.config file and i couldn't extract the data from there by using configurationmanager nor 1.1 feature. do u have any...
2
by: robertino | last post by:
Hi All, (VS 2005 Pro, Win XP Pro) I'm trying to read some app settings from my app.config file (normal Win app), have included the System.Configuration namespace in my app, but when I try to...
3
by: natasha | last post by:
Hello everybody, you can use ConfigurationManager.AppSettings.Set method (ConfigurationManager is in System.Web.Configuration namespace) to store a modified value from web.config. To be...
1
by: shapper | last post by:
Hello, I create a few VB classes under app_code of a web site. Now I am trying to create a library project. Something strange is going on. I have the following line: Dim connectionString As...
3
by: Mark | last post by:
I am trying to read the appsettings section of a configuration file using the ConfigurationManager object (ASP.NET application) with the following three lines but for some reason the...
4
by: Jim in Arizona | last post by:
I've been using VB 2005 for a few years now. My entire coding history is VB related. This weekend I decided to start learning C#. I'm at work now and decided to do some coding in C# that I would...
2
by: remya1000 | last post by:
i'm using VB.NET 2003. Last time while i did a program in Vb.Net 2005, i use "Configuration". and i could read and write to that XML configuration file like the example below. CODES:...
2
by: pantagruel | last post by:
Hi, I have a Visual studio 2005 project that runs as a Windows Service. In it I have declared that I am using System.Configuration. I have set one application setting for the service using the...
3
by: Jeff | last post by:
I have a solution with two projects. Project A is the startup project, while Project B serves as the project with the data logic. At run time, the first thing I need to do is write to Project...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.