DelphiFAQ Home Search:

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

 

comments4 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);
	// ..
}

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.
2007-03-22, 17:18:01
anonymous from Seattle in Washington, United States  
rating
2015-01-30, 00:44:52
anonymous from Netherlands  
Hi Please help I have this web config file.But the fiorfex browser does not show me detailed errors:Sorce script:Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config ><! The section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. ><! The section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. >
2015-01-31, 13:51:52
anonymous  
Hello my family mbemer! I want to say that this article is awesome, nice written and come with approximately all vital infos. I'd like to peer extra posts like this. http://xixldm.com [url= http://lrwmhf.com]l..wmhf[/url] [link= http://fsovuau.com]..uau[/link]

 

 

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: