DelphiFAQ Home Search:

Error message 'the key ... does not exist in the appSettings configuration section'

 

comments15 comments. Current rating: 3 stars (14 votes). Leave comments and/ or rate it.

Question:

I try to compile Visual C++ application that a friend mailed me. The code compiles fine, I can start the application, but when I open a form (dialog), the following exception is thrown:

"the key novelDesign.checked does not exist in the appSettings configuration section"

novelDesign is a radio button in that form. What's going on?

Answer:

Apparantly your friend decided to have default values for the dialog's controls stored in an external .config file. His computer has the config file (typically named application.exe.config or application.config). You could run the application in the debugger and see where it breaks.

It is probably in the InitializeComponent() method, looking as shown in the code below.
Remove the line with the GetValue() reference and it will run fine.

My personal opinion is that default values for dialog controls do not belong in an external .config file anyway.



void InitializeComponent(void) {
	System::Configuration::AppSettingsReader *  configurationAppSettings =
		 new System::Configuration::AppSettingsReader();

	// ..
	// comment out the next line
	this->novelDesign1->Checked = (*__try_cast<__box System::Boolean * >
		(configurationAppSettings->GetValue(S"novelDesign.Checked",
		__typeof(System::Boolean))));

	// the remaing code is ok
	this->novelDesign1->Location = System::Drawing::Point(16, 48);
	// ..
}

Content-type: text/html

Comments:

2006-01-27, 14:17:28
gburcus@hotmail.com from Canada  
Hi,
I have a problem with app.config file to.
I put a connection string inside and I tried to retrieve the information in my application in form constructor after InitializeComponent().
If I am using:
string ConnString =
                    System.Configuration.ConfigurationSettings.AppSettings['ConnectionStringSVH'];

ConnString is null after execurion.
If I’am using:
system.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
                ConnString=((string)(configurationAppSettings.GetValue('ConnStringSVH', typeof(string))));
I got the exception: {'The key 'ConnString' does not exist in the appSettings configuration section.' }
I realize that if I put in Debug directory the config file will be deleted when I run in debug the application.
Any thought?
P.S.1. I rename the config file and put the name of myapp.config
2. I have several project in the same solution Is just in the last one that it didn’t work.
2020-06-23, 11:34:02
Roseann from United Kingdom  
rating
This blog was... how do I say it? Relevant!!
Finally I've found something that helped me.
Cheers!
2020-06-23, 17:49:46
Lizzie from United States  
rating
I enjoy reading an article that will make people think.
Also, many thanks for permitting me to comment!
2020-06-23, 21:46:35
Tabitha from United Kingdom  
rating
I all the time emailed this webpage post page
to all my friends, for the reason that if like to read it afterward my contacts will too.
2020-06-24, 06:56:22
Warren  
rating
cialis 20mg
2020-06-24, 11:45:30
Mary from Germany  
rating
naltrexone 50 mg tablet cost
2020-06-24, 16:08:28
Maple  
rating
Now I am ready to do my breakfast, when having my breakfast coming over again to read other
news.
2020-06-24, 20:00:04
Alba  
rating
buy clomid online without prescription

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: