DelphiFAQ Home Search:

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

 

comments2 comments. Current rating: 3 stars (1 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);
	// ..
}

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.
2007-03-22, 17:18:01
anonymous from Seattle in Washington, United States  
rating

 

 

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: